putout 28.18.0 → 28.19.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 +31 -0
- package/README.md +4 -0
- package/help.json +1 -0
- package/lib/cli/index.js +6 -1
- package/lib/cli/process-file.js +2 -1
- package/lib/putout.js +7 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
2023.03.05, v28.19.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- @putout/formatter-memory: add one more \n to output
|
|
5
|
+
- @putout/formatter-memory: add \n in output
|
|
6
|
+
- @putout/formatter-memory: drop comma
|
|
7
|
+
- @putout/plugin-math: apply-numeric-separators: get back 5 digits min
|
|
8
|
+
- @putout/engine-parser: print: switch to babel/generate only when recast break code
|
|
9
|
+
- @putout/plugin-split-nested-destructuring: property instead of source
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- putout: add --recast option
|
|
13
|
+
- putout: add ability to avoid using recast when fix false
|
|
14
|
+
- @putout/engine-parser: add ability to disable recast
|
|
15
|
+
- eslint-plugin-putout: add-newline-before-function-call: add support of Program body
|
|
16
|
+
- @putout/eslint: createPlugin: improve getSpacesBeforeNode: first node in Program body
|
|
17
|
+
- @putout/test: processor: improve support of UPDATE
|
|
18
|
+
- eslint-plugin-putout: add support of jsx
|
|
19
|
+
- eslint-plugin-putout: array-element-newline: improve support of ArrayExpressions full of Literals with length < 5
|
|
20
|
+
- @putout/test: formatMany: when UPDATE used pass
|
|
21
|
+
- @putout/operate: replaceWith, replaceWithMultiple: improve handling of BlockStatement
|
|
22
|
+
- @putout/formatter-memory: move out maybeZero
|
|
23
|
+
- @putout/engine-parser: switch balanced brackets check to parse
|
|
24
|
+
- @putout/test: when format used with UPDATE pass
|
|
25
|
+
- @putout/formatter-memory: add support of time
|
|
26
|
+
- @putout/plugin-math: apply-numeric-separators: exclude 1e9
|
|
27
|
+
- @putout/engine-parser: try to use babel/generate, when recast produces broken code with additional brace (https://github.com/benjamn/recast/issues/1248)
|
|
28
|
+
- @putout/operator-declare: rm dead code
|
|
29
|
+
- @putout/plugin-promises: remove-useless-await: exclude optional chaining call
|
|
30
|
+
- @putout/plugin-split-nested-destructuring: exclude cases where couple properties used
|
|
31
|
+
|
|
1
32
|
2023.03.02, v28.18.0
|
|
2
33
|
|
|
3
34
|
feature:
|
package/README.md
CHANGED
|
@@ -176,6 +176,7 @@ Options:
|
|
|
176
176
|
--match [pattern] read '.putout.json' and convert 'rules' to 'match' according to 'pattern'
|
|
177
177
|
--flow enable flow
|
|
178
178
|
--fresh generate a fresh cache
|
|
179
|
+
--recast force putout to use recast to find transform places, useful when use babel plugins to make locations more accurate
|
|
179
180
|
--no-config avoid reading '.putout.json'
|
|
180
181
|
--no-ci disable the CI detection
|
|
181
182
|
--no-cache disable the cache
|
|
@@ -208,6 +209,9 @@ putout lib --plugins remove-debugger,remove-unused-variables
|
|
|
208
209
|
- `PUTOUT_FILES` - files that should be processed by putout, divided by ",";
|
|
209
210
|
- `PUTOUT_CONFIG_FILE` - path to 🐊**Putout** config file;
|
|
210
211
|
- `ESLINT_CONFIG_FILE` - path to **ESLint** config file;
|
|
212
|
+
- `NO_ESLINT` - do not run **ESLint** after 🐊**Putout**;
|
|
213
|
+
- `NO_ESLINT_WARNINGS` - do not show **ESLint** warnings;
|
|
214
|
+
- `RECAST` - force 🐊**Putout** to use [`@putout/recast`](https://github.com/putoutjs/recast) to `parse()` and `print()`, useful for Babel Plugins to make locations output more accurate.
|
|
211
215
|
|
|
212
216
|
```sh
|
|
213
217
|
PUTOUT_FILES=lib,test putout --fix
|
package/help.json
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"--match [pattern] ": "read '.putout.json' and convert 'rules' to 'match' according to 'pattern'",
|
|
16
16
|
"--flow ": "enable flow",
|
|
17
17
|
"--fresh ": "generate a fresh cache",
|
|
18
|
+
"--recast ": "force putout to use recast to find transform places, useful when use babel plugins to make locations more accurate",
|
|
18
19
|
"--no-config ": "avoid reading '.putout.json'",
|
|
19
20
|
"--no-ci ": "disable the CI detection",
|
|
20
21
|
"--no-cache ": "disable the cache"
|
package/lib/cli/index.js
CHANGED
|
@@ -43,7 +43,11 @@ const {
|
|
|
43
43
|
const getFormatter = memo(require('./formatter').getFormatter);
|
|
44
44
|
|
|
45
45
|
const cwd = process.cwd();
|
|
46
|
-
const {
|
|
46
|
+
const {
|
|
47
|
+
PUTOUT_FILES = '',
|
|
48
|
+
RECAST,
|
|
49
|
+
} = process.env;
|
|
50
|
+
|
|
47
51
|
const envNames = !PUTOUT_FILES ? [] : PUTOUT_FILES.split(',');
|
|
48
52
|
|
|
49
53
|
const maybeFirst = (a) => isArray(a) ? a.pop() : a;
|
|
@@ -274,6 +278,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
|
|
|
274
278
|
write,
|
|
275
279
|
transform,
|
|
276
280
|
plugins,
|
|
281
|
+
recast: RECAST,
|
|
277
282
|
};
|
|
278
283
|
|
|
279
284
|
const {places, exited} = await run({
|
package/lib/cli/process-file.js
CHANGED
|
@@ -16,7 +16,7 @@ const getMatchedOptions = (name, options) => {
|
|
|
16
16
|
return merge(options, parseMatch(name, options.match));
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
module.exports = ({fix, fixCount, isFlow, logError, raw}) => async ({name, source, startLine, options}) => {
|
|
19
|
+
module.exports = ({fix, fixCount, isFlow, logError, raw, recast}) => async ({name, source, startLine, options}) => {
|
|
20
20
|
const isTS = /\.tsx?$/.test(name) || /{tsx?}$/.test(name);
|
|
21
21
|
const matchedOptions = getMatchedOptions(name, options);
|
|
22
22
|
|
|
@@ -25,6 +25,7 @@ module.exports = ({fix, fixCount, isFlow, logError, raw}) => async ({name, sourc
|
|
|
25
25
|
fixCount,
|
|
26
26
|
isTS,
|
|
27
27
|
isFlow,
|
|
28
|
+
recast,
|
|
28
29
|
...matchedOptions,
|
|
29
30
|
});
|
|
30
31
|
|
package/lib/putout.js
CHANGED
|
@@ -36,8 +36,8 @@ const defaultOpts = (opts = {}) => {
|
|
|
36
36
|
|
|
37
37
|
module.exports = (source, opts) => {
|
|
38
38
|
check(source);
|
|
39
|
-
|
|
40
39
|
opts = defaultOpts(opts);
|
|
40
|
+
|
|
41
41
|
const {
|
|
42
42
|
parser,
|
|
43
43
|
isTS,
|
|
@@ -47,6 +47,8 @@ module.exports = (source, opts) => {
|
|
|
47
47
|
sourceMapName,
|
|
48
48
|
} = opts;
|
|
49
49
|
|
|
50
|
+
const recast = opts.recast ?? opts.fix;
|
|
51
|
+
|
|
50
52
|
const [clearSource, shebang] = cutShebang(source);
|
|
51
53
|
const ast = parse(clearSource, {
|
|
52
54
|
sourceFileName,
|
|
@@ -54,6 +56,7 @@ module.exports = (source, opts) => {
|
|
|
54
56
|
isTS,
|
|
55
57
|
isFlow,
|
|
56
58
|
isJSX,
|
|
59
|
+
recast,
|
|
57
60
|
});
|
|
58
61
|
|
|
59
62
|
const places = transform(ast, source, opts);
|
|
@@ -66,6 +69,7 @@ module.exports = (source, opts) => {
|
|
|
66
69
|
|
|
67
70
|
const printed = print(ast, {
|
|
68
71
|
sourceMapName,
|
|
72
|
+
recast,
|
|
69
73
|
});
|
|
70
74
|
const code = `${shebang}${printed}`;
|
|
71
75
|
|
|
@@ -94,6 +98,7 @@ function transform(ast, source, opts) {
|
|
|
94
98
|
fixCount,
|
|
95
99
|
loadPlugins,
|
|
96
100
|
runPlugins,
|
|
101
|
+
recast = true,
|
|
97
102
|
} = opts;
|
|
98
103
|
|
|
99
104
|
const [, shebang] = cutShebang(source);
|
|
@@ -101,6 +106,7 @@ function transform(ast, source, opts) {
|
|
|
101
106
|
pluginNames,
|
|
102
107
|
cache,
|
|
103
108
|
rules,
|
|
109
|
+
recast,
|
|
104
110
|
});
|
|
105
111
|
|
|
106
112
|
const places = runPlugins({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "28.
|
|
3
|
+
"version": "28.19.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, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
|