putout 25.1.0 → 25.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ChangeLog CHANGED
@@ -1,3 +1,51 @@
1
+ 2022.03.07, v25.3.0
2
+
3
+ feature:
4
+ - (@putout/plugin-try-catch) renamed from @putout/plugin-apply-try-catch
5
+ - (@putout/plugin-apply-try-catch) try-catch: add support of finalizer
6
+ - (@putout/plugin-apply-try-catch) add expand-arguments from @putout/plugin-tape
7
+ - (@putout/plugin-tape) expand-try-catch-arguments: add support of tryCatch with more then one argument
8
+ - (@putout/plugin-regexp) convert-replace-to-replace-all: add support of decoding
9
+ - (@putout/eslint-config) add newline-per-chained-call
10
+ - (@putout/plugin-regexp) convert-replace-to-replace-all: replacer -> traverser: multiple operations on one node
11
+
12
+
13
+ 2022.03.06, v25.2.0
14
+
15
+ fix:
16
+ - (@putout/plugin-apply-try-catch) try-to-catch: report: await
17
+
18
+
19
+ feature:
20
+ - (package) @putout/plugin-remove-useless-escape v3.0.0
21
+ - (putout) convert-replace-to-replace-all: enable since node v16 support
22
+ - (@putout/plugin-remove-useless-escape) drop support of putout < 25
23
+ - (@putout/plugin-regexp) apply-literal-notation: add support of \/
24
+ - (@putout/plugin-remove-useless-escape) add support of \/
25
+
26
+
27
+ 2022.03.05, v25.1.1
28
+
29
+ feature:
30
+ - (package) @putout/plugin-apply-array-at v2.0.0
31
+ - (@putout/plugin-apply-array-at) drop support of putout < 25
32
+ - (@putout/plugin-apply-array-at) report
33
+ - (@putout/plugin-apply-array-at) exclude left of AssignmentExpression
34
+ - (@putout/plugin-promises) remove-useless-await: add support of OptionalCallExpression
35
+ - (@putout/operator-declare) exclude TSDeclareMethod
36
+ - (@putout/operator-declare) exclude TSFunctionType
37
+ - (@putout/plugin-nodejs) declare: rm type
38
+ - (@putout/operator-declare) exclude TSParameterProperty
39
+ - (@putout/operator-declare) exclude TSMethodSignature
40
+ - (@putout/plugin-promise) remove-useless-await: exclude `new await Promise()`
41
+ - (eslint-plugin-putout) ts: disable warn on unsupported version (https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/parser#parseroptionswarnonunsupportedtypescriptversion)
42
+ - (@putout/plugin-apply-try-catch) try-catch: improve filtering of CallExpression
43
+ - (@putout/plugin-apply-try-catch) try-to-catch: improve filtering Await Expressions
44
+ - (eslint-plugin-putout) nonblock-statement-body-newline: add support of for, for-of, while
45
+ - (eslint-plugin-putout) add nonblock-statement-body-newline
46
+ - (eslint-plugin-putout) *.md{js}: enable quotes, quote-props'
47
+
48
+
1
49
  2022.03.01, v25.1.0
2
50
 
3
51
  feature:
package/README.md CHANGED
@@ -7,96 +7,138 @@
7
7
  [CoverageURL]: https://coveralls.io/github/coderaiser/putout?branch=master
8
8
  [CoverageIMGURL]: https://coveralls.io/repos/coderaiser/putout/badge.svg?branch=master&service=github
9
9
 
10
+ > **Perfection is finally attained not when there is no longer anything to add,
11
+ > but when there is no longer anything to take away.**
12
+ >
13
+ > **(c) Antoine de Saint Exupéry**
14
+
10
15
  ![putout](https://github.com/coderaiser/putout/blob/master/images/putout-logo.svg)
11
16
 
12
- 🐊[**Putout**](https://github.com/coderaiser/putout) find and fix problems in your `JavaScript`, `JSX`, `Typescript`, `Flow`, `Yaml, `Json`and`Markdown`. It can:
13
-
14
- - remove unused `variables`;
15
- - remove unused `for-of variables`;
16
- - remove unused `typescripts` types;
17
- - remove unreferenced `variables`;
18
- - remove unused `private fields`;
19
- - remove unused `expressions`;
20
- - remove useless `variables`;
21
- - remove useless `map`;
22
- - remove useless `mapped types`;
23
- - remove useless `mapping modifiers`;
24
- - remove useless `continue`;
25
- - remove useless `operand`;
26
- - remove useless `array constructor`;
27
- - remove useless `conditions`;
28
- - remove useless `type conversion`;
29
- - remove useless `functions`;
30
- - remove useless `Array.from`;
31
- - remove useless `spread`;
32
- - remove useless `arguments`;
33
- - remove useless `escape`;
34
- - remove useless `async`;
35
- - remove useless `await`;
36
- - remove useless `typeof`;
37
- - remove useless `template expressions`;
38
- - remove useless `for-of`;
39
- - remove useless `array.entries()`;
40
- - remove `debugger` statement;
41
- - remove `iife`;
42
- - remove nested blocks;
43
- - remove `process.exit` call;
44
- - remove `console.log` calls;
45
- - remove `empty block statements`;
46
- - remove `empty patterns`;
47
- - remove `strict mode` directive from `esm`;
48
- - remove `constant conditions`;
49
- - remove `boolean` from `assertion`;
50
- - remove `boolean` from `logical expressions`;
51
- - remove `duplicates` from `logical expressions`;
52
- - remove `duplicates` from TypeScript `Union`;
53
- - remove `unreachable code`;
54
- - remove `duplicate keys`;
55
- - remove useless `typescripts` types;
56
- - remove duplicate `typescripts` interface keys;
57
- - replace `test.only` to `test` calls;
58
- - replace `test.skip` to `test` calls;
59
- - reuse duplicate `init`;
60
- - split `variable declarations`;
61
- - split `nested destructuring`;
62
- - simplify `assignment`;
63
- - simplify `ternary`;
64
- - simplify `logical expressions`;
65
- - if absent `strict mode` directive in `commonjs` add it;
66
- - convert `apply` to `spread`;
67
- - convert `bitwise` to `logical` operator;
68
- - convert `concat` to `flat`;
69
- - convert `esm` to `commonjs` (enabled for `*.cjs`);
70
- - convert `commonjs` to `esm` (enabled for `*.mjs`);
71
- - convert `template` with one `expression` to `string`;
72
- - convert `equal` to `strict equal`;
73
- - convert `indexOf` to `includes`;
74
- - convert `replace` to `replaceAll` (disabled, [stage 4](https://github.com/tc39/proposal-string-replaceall));
75
- - convert `assignment` to `arrow function`;
76
- - convert `forEach` to `for-of`;
77
- - convert `map` to `for-of`;
78
- - extract sequence expressions;
79
- - extract object properties;
80
- - add `return await`;
81
- - remove useless `Promise.resolve`;
82
- - convert `Promise.reject` to `throw`;
83
- - declare `undefined variables`;
84
- - apply `as` type assertions;
85
- - apply `utility types`;
86
- - apply `array.at` ([not bundled](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V16.md#2021-07-29-version-1660-current-bethgriggs));
87
- - apply `filter(Boolean)`;
88
- - apply [isArray](https://web.mit.edu/jwalden/www/isArray.html);
89
- - apply `if condition`;
90
- - apply `await import`;
91
-
92
- ## Why?
93
-
94
- - because [eslint](https://eslint.org) avoids [fixes that could change the runtime behavior](https://eslint.org/docs/developer-guide/working-with-rules#applying-fixes).
95
- - because [babel](https://babeljs.io) produces [throw-away code](https://github.com/babel/babel/issues/5139);
96
- - because [pretier](https://github.com/prettier/prettier) it is a formatter;
97
- - because [jscodeshift](https://github.com/facebook/jscodeshift) has no `config` and `plugins` support.
98
-
99
- The main difference of `putout` is saving code transformation results directly into source code in a day-to-day baisis.
17
+ 🐊**Putout** is a pluggable and configurable code transformer with built-in ESLint and Babel plugins support for js, jsx, typescript and flow files. It has [a lot of transformations](#-built-in-transformations) that will keep your codebase in a clean state, transforming any code smell to readable code according to best practices.
18
+
19
+ [![putout](https://asciinema.org/a/0akg9gkJdbmbGl6BbpaycgKZm.svg)](https://asciinema.org/a/0akg9gkJdbmbGl6BbpaycgKZm)
20
+
21
+ ## 🤷‍️ In doubt about using 🐊Putout?
22
+
23
+ Check out couple variants of plugins that does the same: [**linting debugger statement**](https://putout.cloudcmd.io/#/gist/f61ba31fe534868d49eba9b946f3ed4b/5ef6863d9cf4826666782ae0eea5cb5def266bbd):
24
+
25
+ - ESLint [no-debugger](https://github.com/eslint/eslint/blob/2dc38aa653f1d5137a9abf82024c67a11620bb7c/lib/rules/no-debugger.js): **43** lines;
26
+ - SWCLint [no-debugger](https://github.com/swc-project/swc/blob/v1.2.138/crates/swc_ecma_lints/src/rules/no_debugger.rs): **49** lines;
27
+ - Rome [no-debugger](https://github.com/rome/tools/blob/4d5a99ce98e987cbd03f3ab6b38fa22d00bbfe27/packages/%40romejs/js-compiler/transforms/lint/noDebugger.ts): **28** lines;
28
+ - RSLint [no-debugger](https://github.com/rslint/rslint/blob/v0.3.0/crates/rslint_core/src/groups/errors/no_debugger.rs): **48** lines
29
+ - ✅ 🐊**Putout** [remove-debugger](https://github.com/coderaiser/putout/blob/v24.6.0/packages/plugin-remove-debugger/lib/remove-debugger.js): **7** lines:
30
+
31
+ *Choose wisely, competitors cannot even fix…* 🤫
32
+
33
+ ```js
34
+ 'use strict';
35
+
36
+ module.exports.report = () => 'Unexpected "debugger" statement';
37
+
38
+ module.exports.replace = () => ({
39
+ debugger: '',
40
+ });
41
+ ```
42
+
43
+ ## 🙏 Whom should I thank for this project exist?
44
+
45
+ > **If I have seen further, it is by standing upon the shoulders of giants.**
46
+ >
47
+ > **(c) Isaak Newton**
48
+
49
+ - 💪 [**ESLint**](https://eslint.org) for stable releases and future proof `API`.
50
+ - 💪 [**Babel**](https://babeljs.io) for amazing `API` documented in [`Handbook`](https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-plugin-handbook) and responsiveness of a team.
51
+ - 💪 [**Prettier**](https://github.com/prettier/prettier) for minimalistic options and uniform codestyle.
52
+ - 💪 [**jscodeshift**](https://github.com/facebook/jscodeshift) for making codemods simple and popular.
53
+
54
+ ## 🤷 Why does this project exist?
55
+
56
+ - [**ESLint**](https://eslint.org) avoids [fixes that could change the runtime behavior](https://eslint.org/docs/developer-guide/working-with-rules#applying-fixes).
57
+ - [**Babel**](https://babeljs.io) produces [throw-away code](https://github.com/babel/babel/issues/5139).
58
+ - [**Prettier**](https://github.com/prettier/prettier) is a formatter.
59
+ - [**jscodeshift**](https://github.com/facebook/jscodeshift) has no `config` and `plugins` support.
60
+
61
+ ☝️ *🐊**Putout** on the other hand can make more drastic code transformations that directly affect your codebase making it a better place to code 💻.*
62
+
63
+ [It can](https://github.com/coderaiser/putout#-built-in-transformations):
64
+
65
+ - remove unused `variables`;
66
+ - remove unused `for-of variables`;
67
+ - remove unused `typescripts` types;
68
+ - remove unreferenced `variables`;
69
+ - remove unused `private fields`;
70
+ - remove unused `expressions`;
71
+ - remove useless `variables`;
72
+ - remove useless `map`;
73
+ - remove useless `mapped types`;
74
+ - remove useless `mapping modifiers`;
75
+ - remove useless `continue`;
76
+ - remove useless `operand`;
77
+ - remove useless `array constructor`;
78
+ - remove useless `conditions`;
79
+ - remove useless `type conversion`;
80
+ - remove useless `functions`;
81
+ - remove useless `Array.from`;
82
+ - remove useless `spread`;
83
+ - remove useless `arguments`;
84
+ - remove useless `escape`;
85
+ - remove useless `async`;
86
+ - remove useless `await`;
87
+ - remove useless `typeof`;
88
+ - remove useless `template expressions`;
89
+ - remove useless `for-of`;
90
+ - remove useless `array.entries()`;
91
+ - remove `debugger` statement;
92
+ - remove `iife`;
93
+ - remove nested blocks;
94
+ - remove `process.exit` call;
95
+ - remove `console.log` calls;
96
+ - ✅ remove `empty block statements`;
97
+ - ✅ remove `empty patterns`;
98
+ - ✅ remove `strict mode` directive from `esm`;
99
+ - remove `constant conditions`;
100
+ - remove `boolean` from `assertion`;
101
+ - remove `boolean` from `logical expressions`;
102
+ - remove `duplicates` from `logical expressions`;
103
+ - ✅ remove `duplicates` from TypeScript `Union`;
104
+ - remove `unreachable code`;
105
+ - ✅ remove `duplicate keys`;
106
+ - ✅ remove useless `typescripts` types;
107
+ - ✅ remove duplicate `typescripts` interface keys;
108
+ - ✅ replace `test.only` to `test` calls;
109
+ - ✅ replace `test.skip` to `test` calls;
110
+ - ✅ reuse duplicate `init`;
111
+ - ✅ split `variable declarations`;
112
+ - ✅ split `nested destructuring`;
113
+ - ✅ simplify `assignment`;
114
+ - ✅ simplify `ternary`;
115
+ - ✅ simplify `logical expressions`;
116
+ - ✅ if absent `strict mode` directive in `commonjs` add it;
117
+ - ✅ convert `apply` to `spread`;
118
+ - ✅ convert `bitwise` to `logical` operator;
119
+ - ✅ convert `concat` to `flat`;
120
+ - ✅ convert `esm` to `commonjs` (enabled for `*.cjs`);
121
+ - ✅ convert `commonjs` to `esm` (enabled for `*.mjs`);
122
+ - ✅ convert `template` with one `expression` to `string`;
123
+ - ✅ convert `equal` to `strict equal`;
124
+ - ✅ convert `indexOf` to `includes`;
125
+ - ✅ convert `replace` to `replaceAll` (disabled, [stage 4](https://github.com/tc39/proposal-string-replaceall));
126
+ - ✅ convert `assignment` to `arrow function`;
127
+ - ✅ convert `forEach` to `for-of`;
128
+ - ✅ convert `map` to `for-of`;
129
+ - ✅ extract sequence expressions;
130
+ - ✅ extract object properties;
131
+ - ✅ add `return await`;
132
+ - ✅ remove useless `Promise.resolve`;
133
+ - ✅ convert `Promise.reject` to `throw`;
134
+ - ✅ declare `undefined variables`;
135
+ - ✅ apply `as` type assertions;
136
+ - ✅ apply `utility types`;
137
+ - ✅ apply `array.at` ([not bundled](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V16.md#2021-07-29-version-1660-current-bethgriggs));
138
+ - ✅ apply `filter(Boolean)`;
139
+ - ✅ apply [isArray](https://web.mit.edu/jwalden/www/isArray.html);
140
+ - ✅ apply `if condition`;
141
+ - ✅ apply `await import`;
100
142
 
101
143
  ## Install
102
144
 
@@ -130,7 +172,7 @@ Options:
130
172
  --no-cache disable the cache
131
173
  ```
132
174
 
133
- To find erros:
175
+ To find errors:
134
176
 
135
177
  ```
136
178
  putout lib test
@@ -156,7 +198,7 @@ putout lib --plugins remove-debugger,remove-unused-variables
156
198
 
157
199
  - `PUTOUT_FILES` - files that should be processed by putout, divided by ",";
158
200
  - `PUTOUT_CONFIG_FILE` - path to 🐊**Putout** config file;
159
- - `ESLINT_CONFIG_FILE` - path to `ESLint` config file;
201
+ - `ESLINT_CONFIG_FILE` - path to **ESLint** config file;
160
202
 
161
203
  ```sh
162
204
  PUTOUT_FILES=lib,test putout --fix
@@ -194,7 +236,12 @@ When you need to ignore some routes no metter what, you can use `ignore` section
194
236
 
195
237
  ## Plugins
196
238
 
197
- 🐊**Putout** supports `plugins`, there is two types: with prefix official `@putout/plugin-` and user plugins with prefix `putout-plugin-`. To use your plugin create plugin as `npm` package with keywords `putout`, `putout-plugin` and add it to `.putout.json`.
239
+ 🐊**Putout** supports two types of `plugins`, prefix with:
240
+
241
+ - ✅ `@putout/plugin-`;
242
+ - ✅ `putout-plugin-`;
243
+
244
+ To use your plugin create`npm` package with keywords `putout`, `putout-plugin` and add it to `.putout.json`.
198
245
 
199
246
  For example if you need to `remove-something` create 🐊[**Putout**](https://github.com/coderaiser/putout) plugin with name `putout-plugin-remove-something` and it to `package.json`:
200
247
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "25.1.0",
3
+ "version": "25.3.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊 Pluggable and configurable code transformer with built-in eslint and babel plugins support of js, jsx typescript, flow files, markdown, yaml and json",
@@ -70,14 +70,13 @@
70
70
  "@putout/operator-add-args": "^3.0.0",
71
71
  "@putout/operator-declare": "^4.0.0",
72
72
  "@putout/operator-regexp": "^1.0.0",
73
- "@putout/plugin-apply-array-at": "^1.0.0",
73
+ "@putout/plugin-apply-array-at": "^2.0.0",
74
74
  "@putout/plugin-apply-await-import": "^1.0.0",
75
75
  "@putout/plugin-apply-destructuring": "^5.0.0",
76
76
  "@putout/plugin-apply-if-condition": "^1.0.0",
77
77
  "@putout/plugin-apply-is-array": "^2.0.0",
78
78
  "@putout/plugin-apply-numeric-separators": "^1.0.0",
79
79
  "@putout/plugin-apply-optional-chaining": "^2.0.0",
80
- "@putout/plugin-apply-try-catch": "^2.0.0",
81
80
  "@putout/plugin-browserlist": "^1.0.0",
82
81
  "@putout/plugin-convert-apply-to-spread": "^3.0.0",
83
82
  "@putout/plugin-convert-arguments-to-rest": "^1.0.0",
@@ -143,7 +142,7 @@
143
142
  "@putout/plugin-remove-useless-conditions": "^1.0.0",
144
143
  "@putout/plugin-remove-useless-constructor": "^1.0.0",
145
144
  "@putout/plugin-remove-useless-continue": "^1.0.0",
146
- "@putout/plugin-remove-useless-escape": "^2.0.0",
145
+ "@putout/plugin-remove-useless-escape": "^3.0.0",
147
146
  "@putout/plugin-remove-useless-for-of": "^2.0.0",
148
147
  "@putout/plugin-remove-useless-functions": "^2.0.0",
149
148
  "@putout/plugin-remove-useless-map": "^1.0.0",
@@ -163,6 +162,7 @@
163
162
  "@putout/plugin-split-variable-declarations": "^2.0.0",
164
163
  "@putout/plugin-strict-mode": "^3.0.0",
165
164
  "@putout/plugin-tape": "^9.0.0",
165
+ "@putout/plugin-try-catch": "^1.0.0",
166
166
  "@putout/plugin-typescript": "^1.0.0",
167
167
  "@putout/plugin-webpack": "^1.0.0",
168
168
  "@putout/processor-css": "^3.0.0",
package/putout.json CHANGED
@@ -119,7 +119,6 @@
119
119
  "github": "off",
120
120
  "tape": "off",
121
121
  "strict-mode": "off",
122
- "regexp/convert-replace-to-replace-all": "off",
123
122
  "convert-mock-require-to-mock-import": "off"
124
123
  },
125
124
  "plugins": [
@@ -130,7 +129,6 @@
130
129
  "apply-optional-chaining",
131
130
  "apply-numeric-separators",
132
131
  "apply-if-condition",
133
- "apply-try-catch",
134
132
  "extract-object-properties",
135
133
  "extract-sequence-expressions",
136
134
  "madrun",
@@ -217,6 +215,7 @@
217
215
  "regexp",
218
216
  "github",
219
217
  "tape",
218
+ "try-catch",
220
219
  "nodejs"
221
220
  ]
222
221
  }