putout 24.3.0 → 25.0.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 +89 -0
- package/lib/cli/index.js +31 -138
- package/lib/cli/process-file.js +2 -3
- package/lib/cli/runner/runner.js +49 -0
- package/lib/cli/runner/worker.js +146 -0
- package/lib/putout.mjs +1 -1
- package/package.json +14 -12
- package/putout.json +1 -0
package/ChangeLog
CHANGED
|
@@ -1,3 +1,92 @@
|
|
|
1
|
+
2022.02.17, v25.0.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- docs(eslint-plugin-putout) safe: add "plugin-" prefix
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- (package) @putout/plugin-github v3.0.0
|
|
8
|
+
- (putout) drop support of node < 16
|
|
9
|
+
- (@putout/plugin-github) set-node-versions: 14, 16, 17 -> 16, 17
|
|
10
|
+
- (@putout/plugin-github) drop support of putout < 25
|
|
11
|
+
- (package) @putout/operator-declare v4.0.0
|
|
12
|
+
- (package) @putout/plugin-convert-map-to-for-of v2.0.0
|
|
13
|
+
- (package) @putout/plugin-regexp v5.0.0
|
|
14
|
+
- (package) @putout/processor-markdown v6.0.0
|
|
15
|
+
- (@putout/processor-markdown) drop support of putout < 25
|
|
16
|
+
- (@putout/plugin-regexp) drop support of putout < 25
|
|
17
|
+
- (@putout/plugin-convert-map-to-for-of) drop support of putout < 25
|
|
18
|
+
- (@putout/operator-declare) drop support of putout < 25
|
|
19
|
+
- (putout) add @putout/plugin-apply-array-at
|
|
20
|
+
- (@putout/plugin-remove-unused-variables) get-vars: getScopeUID: rm useless done
|
|
21
|
+
- (@putout/operator-declare) parseCode: rm useless name argument
|
|
22
|
+
- (@putout/test) supertape v7.0.0
|
|
23
|
+
- (@putout/test) reuse options
|
|
24
|
+
- (eslint-plugin-putout) add remove-newline-after-last-element (#95)
|
|
25
|
+
- (@putout/plugin-putout) add convert-match-to-function
|
|
26
|
+
- (@putout/plugin-putout) check-replace-code: add support of ObjectExpression
|
|
27
|
+
- (@putout/plugin-putout) add convert-replace-to-function
|
|
28
|
+
- (@putout/engine-runner) replace: add match property value validation: `☝️ Looks like 'match' property value is not a 'function', but 'string' with value 'xxx'.`
|
|
29
|
+
- (@putout/engine-loader) validate-plugin: improve error message: `☝️ Cannot determine type of plugin fn. Here is list of supported plugins: https://git.io/JqcMn`
|
|
30
|
+
- (@putout/plugin-remove-empty) pattern: improve support of function arguments
|
|
31
|
+
- (@putout/engine-runner) add `☝️ Looks like you passed template value with a wrong type. Allowed: string, node and path. Received: true`
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
2022.02.07, v24.6.0
|
|
35
|
+
|
|
36
|
+
fix:
|
|
37
|
+
- (eslint-plugin-putout) remove parent: after parse -> before print
|
|
38
|
+
- (eslint-plugin-putout) npmignore: add lib/**/*.md
|
|
39
|
+
- chore(madrun) add fresh:fix
|
|
40
|
+
|
|
41
|
+
feature:
|
|
42
|
+
- (package) @putout/plugin-remove-empty v7.0.0
|
|
43
|
+
- (package) @putout/plugin-promises v7.0.0
|
|
44
|
+
- (@putout/plugin-remove-empty) drop support of 🐊Putout < 24
|
|
45
|
+
- (@putout/plugin-remove-empty) merge remove-empty-pattern
|
|
46
|
+
- (@putout/plugin-promises) merge remove-useless-await
|
|
47
|
+
- (@putout/plugin-promises) merged remove-useless-async
|
|
48
|
+
- (@putout/plugin-promises) drop support of 🐊Putout < 24
|
|
49
|
+
- (@putout/plugin-promises) merged apply-top-level-await
|
|
50
|
+
- (@putout/plugin-remove-useless-variables) destruct: add support of AssignmentPattern
|
|
51
|
+
- (@putout/plugin-remove-useless-variables) destr: add support of RestElement
|
|
52
|
+
- (eslint-plugin-putout) function-declaration-parent-newline: improve support of destructuring
|
|
53
|
+
- (@putout/engine-parser) add support of wasm-based hermes-parser (5 times slower then babel 🤔)
|
|
54
|
+
- (@putout/plugin-remove-unused-variables) add support of ClassProperty (#96)
|
|
55
|
+
- (@putout/plugin-apply-try-catch) await: add support of async
|
|
56
|
+
- (@putout/plugin-putout) check-replace-code: exclude plugins containing match
|
|
57
|
+
- (@putout/plugin-apply-try-catch) add await
|
|
58
|
+
- (eslint-plugin-putout) function-declaration-paren-newline: add FunctionExpression support
|
|
59
|
+
- (@putout/plugin-remove-useless-variables) add destruct
|
|
60
|
+
- (eslint-plugin-putout) safe: disable remove-useless-spread
|
|
61
|
+
- (@putout/eslint-config) operator-linebreak: add ":", "?"
|
|
62
|
+
- (@putout/eslint-config) operand-linebreak: |, || - before, others - after
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
2022.01.26, v24.5.0
|
|
66
|
+
|
|
67
|
+
fix:
|
|
68
|
+
- (putout) rm unused thread-it
|
|
69
|
+
|
|
70
|
+
feature:
|
|
71
|
+
- (package) @putout/plugin-strict-mode v3.0.0
|
|
72
|
+
- (package) @putout/compare v8.7.0
|
|
73
|
+
- (@putout/compare) add findUp option
|
|
74
|
+
- (@putout/compare) add support of findUp
|
|
75
|
+
- (@putout/plugin-strict-mode) drop support of putout < 24
|
|
76
|
+
- (@putout/plugin-strict-mode) commonjs -> CommonJS
|
|
77
|
+
- (@putout/plugin-strict-mode) is esm -> in ESM
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
2022.01.25, v24.4.0
|
|
81
|
+
|
|
82
|
+
feature:
|
|
83
|
+
- (putout) cli: move out runner
|
|
84
|
+
- (@putout/eslint-config) padding-line-between-statements: add import
|
|
85
|
+
- (@putout/eslint-config) padding-line-between-statements: add export
|
|
86
|
+
- (@putout/eslint-config) enable operator-linebreak
|
|
87
|
+
- (@putout/test) add ESLint support
|
|
88
|
+
|
|
89
|
+
|
|
1
90
|
2022.01.24, v24.3.0
|
|
2
91
|
|
|
3
92
|
feature:
|
package/lib/cli/index.js
CHANGED
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {resolve} = require('path');
|
|
4
|
-
const {readFileSync} = require('fs');
|
|
5
|
-
|
|
6
3
|
const {red} = require('chalk');
|
|
7
4
|
const yargsParser = require('yargs-parser');
|
|
8
5
|
const {isCI} = require('ci-info');
|
|
9
6
|
const memo = require('nano-memoize');
|
|
10
|
-
const fullstore = require('fullstore');
|
|
11
7
|
const tryCatch = require('try-catch');
|
|
12
|
-
const tryToCatch = require('try-to-catch');
|
|
13
8
|
const wraptile = require('wraptile');
|
|
9
|
+
const fullstore = require('fullstore');
|
|
10
|
+
|
|
11
|
+
const keyPress = require('@putout/cli-keypress');
|
|
14
12
|
const {version} = require('../../package.json');
|
|
15
13
|
const {simpleImport} = require('./simple-import');
|
|
16
|
-
|
|
17
|
-
const {env} = process;
|
|
18
|
-
const isIDE = /JetBrains/.test(env.TERMINAL_EMULATOR) || env.TERM_PROGRAM === 'vscode';
|
|
19
|
-
const chooseName = (name, resolvedName) => !isIDE ? name : resolvedName;
|
|
14
|
+
const {run} = require('./runner/runner.js');
|
|
20
15
|
|
|
21
16
|
const {
|
|
22
|
-
runProcessors,
|
|
23
17
|
getFilePatterns,
|
|
24
18
|
getProcessorRunners,
|
|
25
19
|
defaultProcessors,
|
|
26
20
|
} = require('@putout/engine-processor');
|
|
27
21
|
|
|
28
22
|
const merge = require('../merge');
|
|
29
|
-
const ignores = require('../ignores');
|
|
30
23
|
|
|
31
|
-
const initProcessFile = require('./process-file');
|
|
32
24
|
const getFiles = require('./get-files');
|
|
33
25
|
const {createCache} = require('@putout/cli-cache');
|
|
34
26
|
const supportedFiles = require('./supported-files');
|
|
35
27
|
const getFormatter = memo(require('./formatter').getFormatter);
|
|
36
28
|
const getOptions = require('./get-options');
|
|
37
|
-
|
|
38
|
-
const keyPress = require('@putout/cli-keypress');
|
|
29
|
+
|
|
39
30
|
const validateArgs = require('@putout/cli-validate-args');
|
|
40
|
-
const parseError = require('./parse-error');
|
|
41
31
|
|
|
42
32
|
const {
|
|
43
33
|
OK,
|
|
44
34
|
PLACE,
|
|
45
35
|
STAGE,
|
|
46
36
|
NO_FILES,
|
|
47
|
-
NO_PROCESSORS,
|
|
48
37
|
CANNOT_LOAD_PROCESSOR,
|
|
49
38
|
WAS_STOP,
|
|
50
39
|
INVALID_OPTION,
|
|
@@ -64,20 +53,6 @@ const getExitCode = (wasStop) => wasStop() ? WAS_STOP : OK;
|
|
|
64
53
|
|
|
65
54
|
const isStr = (a) => typeof a === 'string';
|
|
66
55
|
const {isArray} = Array;
|
|
67
|
-
const isParser = (rule) => /^parser/.test(rule);
|
|
68
|
-
const isParsingError = ({rule}) => isParser(rule);
|
|
69
|
-
|
|
70
|
-
const createFormatterProxy = (options) => {
|
|
71
|
-
return new Proxy(options, {
|
|
72
|
-
get(target, name) {
|
|
73
|
-
if (target[name])
|
|
74
|
-
return target[name];
|
|
75
|
-
|
|
76
|
-
if (name === 'source')
|
|
77
|
-
return readFileSync(target.name, 'utf8');
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
56
|
|
|
82
57
|
module.exports = async ({argv, halt, log, write, logError, readFile, writeFile}) => {
|
|
83
58
|
const {isStop} = keyPress();
|
|
@@ -299,114 +274,29 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
|
|
|
299
274
|
plugins,
|
|
300
275
|
};
|
|
301
276
|
|
|
302
|
-
const rawPlaces =
|
|
277
|
+
const {rawPlaces, exited} = await run({
|
|
278
|
+
fix,
|
|
279
|
+
exit,
|
|
280
|
+
readFile,
|
|
281
|
+
writeFile,
|
|
282
|
+
raw,
|
|
283
|
+
rulesdir,
|
|
284
|
+
names,
|
|
285
|
+
options,
|
|
286
|
+
fileCache,
|
|
287
|
+
currentFormat,
|
|
288
|
+
formatterOptions,
|
|
289
|
+
write,
|
|
290
|
+
log,
|
|
291
|
+
isStop,
|
|
292
|
+
wasStop,
|
|
293
|
+
noConfig,
|
|
294
|
+
plugins,
|
|
295
|
+
transform,
|
|
296
|
+
});
|
|
303
297
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
for (let index = 0; index < length; index++) {
|
|
308
|
-
if (wasStop())
|
|
309
|
-
break;
|
|
310
|
-
|
|
311
|
-
wasStop(isStop());
|
|
312
|
-
|
|
313
|
-
const currentIndex = isStop() ? length - 1 : index;
|
|
314
|
-
const name = names[index];
|
|
315
|
-
const resolvedName = resolve(name)
|
|
316
|
-
.replace(/^\./, cwd);
|
|
317
|
-
|
|
318
|
-
const [configError, options] = tryCatch(getOptions, {
|
|
319
|
-
name: resolvedName,
|
|
320
|
-
rulesdir,
|
|
321
|
-
noConfig,
|
|
322
|
-
transform,
|
|
323
|
-
plugins,
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
if (configError)
|
|
327
|
-
return exit(INVALID_CONFIG, configError);
|
|
328
|
-
|
|
329
|
-
const {dir} = options;
|
|
330
|
-
|
|
331
|
-
if (fileCache.canUseCache(name, options)) {
|
|
332
|
-
const places = fileCache.getPlaces(name);
|
|
333
|
-
const formatterProxy = createFormatterProxy({
|
|
334
|
-
report,
|
|
335
|
-
formatterOptions,
|
|
336
|
-
name: chooseName(name, resolvedName),
|
|
337
|
-
places,
|
|
338
|
-
index: currentIndex,
|
|
339
|
-
count: length,
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
const line = await report(currentFormat, formatterProxy);
|
|
343
|
-
|
|
344
|
-
write(line || '');
|
|
345
|
-
rawPlaces.push(places);
|
|
346
|
-
continue;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
let isProcessed = true;
|
|
350
|
-
let places = [];
|
|
351
|
-
let rawSource = '';
|
|
352
|
-
let processedSource = '';
|
|
353
|
-
|
|
354
|
-
if (!ignores(dir, resolvedName, options)) {
|
|
355
|
-
rawSource = await readFile(resolvedName, 'utf8');
|
|
356
|
-
|
|
357
|
-
const [error, result] = await tryToCatch(runProcessors, {
|
|
358
|
-
name: resolvedName,
|
|
359
|
-
fix,
|
|
360
|
-
processFile,
|
|
361
|
-
options,
|
|
362
|
-
rawSource,
|
|
363
|
-
processorRunners,
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
if (error) {
|
|
367
|
-
places = parseError(error);
|
|
368
|
-
|
|
369
|
-
isProcessed = true;
|
|
370
|
-
processedSource = rawSource;
|
|
371
|
-
|
|
372
|
-
if (raw)
|
|
373
|
-
log(error);
|
|
374
|
-
} else {
|
|
375
|
-
({
|
|
376
|
-
isProcessed,
|
|
377
|
-
places,
|
|
378
|
-
processedSource,
|
|
379
|
-
} = result);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
const line = await report(currentFormat, {
|
|
384
|
-
report,
|
|
385
|
-
formatterOptions,
|
|
386
|
-
name: chooseName(name, resolvedName),
|
|
387
|
-
source: rawSource,
|
|
388
|
-
places,
|
|
389
|
-
index: currentIndex,
|
|
390
|
-
count: length,
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
write(line || '');
|
|
394
|
-
|
|
395
|
-
if (!isProcessed)
|
|
396
|
-
return exit(NO_PROCESSORS, Error(`No processors found for ${name}`));
|
|
397
|
-
|
|
398
|
-
if (rawSource !== processedSource) {
|
|
399
|
-
fileCache.removeEntry(name);
|
|
400
|
-
await writeFile(name, processedSource);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
const fixable = !places.filter(isParsingError).length;
|
|
404
|
-
|
|
405
|
-
if (fixable)
|
|
406
|
-
fileCache.setInfo(name, places, options);
|
|
407
|
-
|
|
408
|
-
rawPlaces.push(places);
|
|
409
|
-
}
|
|
298
|
+
if (exited)
|
|
299
|
+
return;
|
|
410
300
|
|
|
411
301
|
const mergedPlaces = merge(...rawPlaces);
|
|
412
302
|
|
|
@@ -445,6 +335,10 @@ const getExit = ({halt, raw, logError}) => (code, e) => {
|
|
|
445
335
|
|
|
446
336
|
logError(message);
|
|
447
337
|
halt(code);
|
|
338
|
+
|
|
339
|
+
return {
|
|
340
|
+
exited: true,
|
|
341
|
+
};
|
|
448
342
|
};
|
|
449
343
|
|
|
450
344
|
module.exports._addOnce = addOnce;
|
|
@@ -452,4 +346,3 @@ function addOnce(emitter, name, fn) {
|
|
|
452
346
|
if (!emitter.listenerCount(name))
|
|
453
347
|
emitter.on(name, fn);
|
|
454
348
|
}
|
|
455
|
-
|
package/lib/cli/process-file.js
CHANGED
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
const tryCatch = require('try-catch');
|
|
4
4
|
|
|
5
5
|
const putout = require('../..');
|
|
6
|
+
const merge = require('../merge');
|
|
7
|
+
const parseMatch = require('../parse-options/parse-match');
|
|
6
8
|
|
|
7
9
|
const eslint = require('./eslint');
|
|
8
10
|
const parseError = require('./parse-error');
|
|
9
11
|
|
|
10
|
-
const merge = require('../merge');
|
|
11
|
-
const parseMatch = require('../parse-options/parse-match');
|
|
12
|
-
|
|
13
12
|
const getMatchedOptions = (name, options) => {
|
|
14
13
|
if (!name.includes('{'))
|
|
15
14
|
return options;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const runWorker = require('./worker.js');
|
|
4
|
+
const initProcessFile = require('../process-file.js');
|
|
5
|
+
const Report = require('../report.js');
|
|
6
|
+
|
|
7
|
+
const report = Report();
|
|
8
|
+
|
|
9
|
+
module.exports.run = async ({transform, plugins, noConfig, readFile, writeFile, exit, isStop, wasStop, names, write, log, rulesdir, fix, processorRunners, fileCache, currentFormat, formatterOptions, options, raw}) => {
|
|
10
|
+
const processFile = initProcessFile(options);
|
|
11
|
+
const {length} = names;
|
|
12
|
+
const rawPlaces = [];
|
|
13
|
+
|
|
14
|
+
for (let index = 0; index < length; index++) {
|
|
15
|
+
if (wasStop())
|
|
16
|
+
break;
|
|
17
|
+
|
|
18
|
+
const {exited} = await runWorker({
|
|
19
|
+
readFile,
|
|
20
|
+
writeFile,
|
|
21
|
+
exit,
|
|
22
|
+
isStop,
|
|
23
|
+
wasStop,
|
|
24
|
+
fix,
|
|
25
|
+
processorRunners,
|
|
26
|
+
rulesdir,
|
|
27
|
+
currentFormat,
|
|
28
|
+
formatterOptions,
|
|
29
|
+
index,
|
|
30
|
+
names,
|
|
31
|
+
length,
|
|
32
|
+
rawPlaces,
|
|
33
|
+
processFile,
|
|
34
|
+
fileCache,
|
|
35
|
+
raw,
|
|
36
|
+
write,
|
|
37
|
+
log,
|
|
38
|
+
report,
|
|
39
|
+
noConfig,
|
|
40
|
+
plugins,
|
|
41
|
+
transform,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (exited)
|
|
45
|
+
return {exited, rawPlaces};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {rawPlaces};
|
|
49
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {resolve} = require('path');
|
|
4
|
+
const {
|
|
5
|
+
cwd,
|
|
6
|
+
env,
|
|
7
|
+
} = require('process');
|
|
8
|
+
const tryCatch = require('try-catch');
|
|
9
|
+
const {readFileSync} = require('fs');
|
|
10
|
+
const tryToCatch = require('try-to-catch');
|
|
11
|
+
const {runProcessors} = require('@putout/engine-processor');
|
|
12
|
+
|
|
13
|
+
const parseError = require('../parse-error.js');
|
|
14
|
+
const getOptions = require('../get-options.js');
|
|
15
|
+
const {
|
|
16
|
+
INVALID_CONFIG,
|
|
17
|
+
NO_PROCESSORS,
|
|
18
|
+
} = require('../exit-codes.js');
|
|
19
|
+
const ignores = require('../../ignores.js');
|
|
20
|
+
|
|
21
|
+
const isParser = (rule) => /^parser/.test(rule);
|
|
22
|
+
const isParsingError = ({rule}) => isParser(rule);
|
|
23
|
+
const chooseName = (name, resolvedName) => !isIDE ? name : resolvedName;
|
|
24
|
+
const isIDE = /JetBrains/.test(env.TERMINAL_EMULATOR) || env.TERM_PROGRAM === 'vscode';
|
|
25
|
+
|
|
26
|
+
const createFormatterProxy = (options) => {
|
|
27
|
+
return new Proxy(options, {
|
|
28
|
+
get(target, name) {
|
|
29
|
+
if (target[name])
|
|
30
|
+
return target[name];
|
|
31
|
+
|
|
32
|
+
if (name === 'source')
|
|
33
|
+
return readFileSync(target.name, 'utf8');
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
module.exports = async ({readFile, report, writeFile, exit, raw, write, log, currentFormat, rulesdir, formatterOptions, noConfig, transform, plugins, index, fix, processFile, processorRunners, fileCache, rawPlaces, wasStop, isStop, names, length}) => {
|
|
39
|
+
wasStop(isStop());
|
|
40
|
+
|
|
41
|
+
const currentIndex = isStop() ? length - 1 : index;
|
|
42
|
+
const name = names[index];
|
|
43
|
+
const resolvedName = resolve(name)
|
|
44
|
+
.replace(/^\./, cwd);
|
|
45
|
+
|
|
46
|
+
const [configError, options] = tryCatch(getOptions, {
|
|
47
|
+
name: resolvedName,
|
|
48
|
+
rulesdir,
|
|
49
|
+
noConfig,
|
|
50
|
+
transform,
|
|
51
|
+
plugins,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (configError)
|
|
55
|
+
return exit(INVALID_CONFIG, configError);
|
|
56
|
+
|
|
57
|
+
const {dir} = options;
|
|
58
|
+
|
|
59
|
+
if (fileCache.canUseCache(name, options)) {
|
|
60
|
+
const places = fileCache.getPlaces(name);
|
|
61
|
+
const formatterProxy = createFormatterProxy({
|
|
62
|
+
report,
|
|
63
|
+
formatterOptions,
|
|
64
|
+
name: chooseName(name, resolvedName),
|
|
65
|
+
places,
|
|
66
|
+
index: currentIndex,
|
|
67
|
+
count: length,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const line = await report(currentFormat, formatterProxy);
|
|
71
|
+
|
|
72
|
+
write(line || '');
|
|
73
|
+
rawPlaces.push(places);
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
success: true,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let isProcessed = true;
|
|
81
|
+
let places = [];
|
|
82
|
+
let rawSource = '';
|
|
83
|
+
let processedSource = '';
|
|
84
|
+
|
|
85
|
+
if (!ignores(dir, resolvedName, options)) {
|
|
86
|
+
rawSource = await readFile(resolvedName, 'utf8');
|
|
87
|
+
|
|
88
|
+
const [error, result] = await tryToCatch(runProcessors, {
|
|
89
|
+
name: resolvedName,
|
|
90
|
+
fix,
|
|
91
|
+
processFile,
|
|
92
|
+
options,
|
|
93
|
+
rawSource,
|
|
94
|
+
processorRunners,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (error) {
|
|
98
|
+
places = parseError(error);
|
|
99
|
+
|
|
100
|
+
isProcessed = true;
|
|
101
|
+
processedSource = rawSource;
|
|
102
|
+
|
|
103
|
+
if (raw)
|
|
104
|
+
log(error);
|
|
105
|
+
} else {
|
|
106
|
+
({
|
|
107
|
+
isProcessed,
|
|
108
|
+
places,
|
|
109
|
+
processedSource,
|
|
110
|
+
} = result);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const line = await report(currentFormat, {
|
|
115
|
+
report,
|
|
116
|
+
formatterOptions,
|
|
117
|
+
name: chooseName(name, resolvedName),
|
|
118
|
+
source: rawSource,
|
|
119
|
+
places,
|
|
120
|
+
index: currentIndex,
|
|
121
|
+
count: length,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
write(line || '');
|
|
125
|
+
|
|
126
|
+
if (!isProcessed)
|
|
127
|
+
return exit(NO_PROCESSORS, Error(`No processors found for ${name}`));
|
|
128
|
+
|
|
129
|
+
if (rawSource !== processedSource) {
|
|
130
|
+
fileCache.removeEntry(name);
|
|
131
|
+
await writeFile(name, processedSource);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const fixable = !places.filter(isParsingError).length;
|
|
135
|
+
|
|
136
|
+
if (fixable)
|
|
137
|
+
fileCache.setInfo(name, places, options);
|
|
138
|
+
|
|
139
|
+
rawPlaces.push(places);
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
rawPlaces,
|
|
143
|
+
success: true,
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
package/lib/putout.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.0.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",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"./process-file": "./lib/cli/process-file.js",
|
|
17
17
|
"./exit-codes": "./lib/cli/exit-codes.mjs",
|
|
18
18
|
"./cli": "./lib/cli/index.js",
|
|
19
|
+
"./cli/run": "./lib/cli/runner/work",
|
|
19
20
|
"./loader": "./lib/loader.mjs",
|
|
20
21
|
"./eslint": "./lib/cli/eslint/index.js",
|
|
21
22
|
"./package.json": "./package.json"
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"@putout/cli-match": "^1.0.0",
|
|
52
53
|
"@putout/cli-ruler": "^2.0.0",
|
|
53
54
|
"@putout/cli-validate-args": "^1.0.0",
|
|
54
|
-
"@putout/compare": "^8.
|
|
55
|
+
"@putout/compare": "^8.7.0",
|
|
55
56
|
"@putout/engine-loader": "^5.0.0",
|
|
56
57
|
"@putout/engine-parser": "^4.0.0",
|
|
57
58
|
"@putout/engine-processor": "^4.0.0",
|
|
@@ -67,8 +68,9 @@
|
|
|
67
68
|
"@putout/formatter-stream": "^3.0.0",
|
|
68
69
|
"@putout/operate": "^7.0.0",
|
|
69
70
|
"@putout/operator-add-args": "^2.0.0",
|
|
70
|
-
"@putout/operator-declare": "^
|
|
71
|
+
"@putout/operator-declare": "^4.0.0",
|
|
71
72
|
"@putout/operator-regexp": "^1.0.0",
|
|
73
|
+
"@putout/plugin-apply-array-at": "^1.0.0",
|
|
72
74
|
"@putout/plugin-apply-await-import": "^1.0.0",
|
|
73
75
|
"@putout/plugin-apply-destructuring": "^5.0.0",
|
|
74
76
|
"@putout/plugin-apply-if-condition": "^1.0.0",
|
|
@@ -91,7 +93,7 @@
|
|
|
91
93
|
"@putout/plugin-convert-for-in-to-for-of": "^2.0.0",
|
|
92
94
|
"@putout/plugin-convert-for-to-for-of": "^3.0.0",
|
|
93
95
|
"@putout/plugin-convert-index-of-to-includes": "^1.0.0",
|
|
94
|
-
"@putout/plugin-convert-map-to-for-of": "^
|
|
96
|
+
"@putout/plugin-convert-map-to-for-of": "^2.0.0",
|
|
95
97
|
"@putout/plugin-convert-math-pow": "^4.0.0",
|
|
96
98
|
"@putout/plugin-convert-mock-require-to-mock-import": "^2.0.0",
|
|
97
99
|
"@putout/plugin-convert-object-assign-to-merge-spread": "^5.0.0",
|
|
@@ -103,7 +105,7 @@
|
|
|
103
105
|
"@putout/plugin-eslint": "^2.0.0",
|
|
104
106
|
"@putout/plugin-extract-object-properties": "^7.0.0",
|
|
105
107
|
"@putout/plugin-extract-sequence-expressions": "^2.0.0",
|
|
106
|
-
"@putout/plugin-github": "^
|
|
108
|
+
"@putout/plugin-github": "^3.0.0",
|
|
107
109
|
"@putout/plugin-gitignore": "^3.0.0",
|
|
108
110
|
"@putout/plugin-madrun": "^13.0.0",
|
|
109
111
|
"@putout/plugin-merge-destructuring-properties": "^6.0.0",
|
|
@@ -112,10 +114,10 @@
|
|
|
112
114
|
"@putout/plugin-nodejs": "^2.0.0",
|
|
113
115
|
"@putout/plugin-npmignore": "^2.0.0",
|
|
114
116
|
"@putout/plugin-package-json": "^3.0.0",
|
|
115
|
-
"@putout/plugin-promises": "^
|
|
117
|
+
"@putout/plugin-promises": "^7.0.0",
|
|
116
118
|
"@putout/plugin-putout": "^10.0.0",
|
|
117
119
|
"@putout/plugin-putout-config": "^2.0.0",
|
|
118
|
-
"@putout/plugin-regexp": "^
|
|
120
|
+
"@putout/plugin-regexp": "^5.0.0",
|
|
119
121
|
"@putout/plugin-remove-boolean-from-assertions": "^1.0.0",
|
|
120
122
|
"@putout/plugin-remove-boolean-from-logical-expressions": "^4.0.0",
|
|
121
123
|
"@putout/plugin-remove-console": "^3.0.0",
|
|
@@ -124,7 +126,7 @@
|
|
|
124
126
|
"@putout/plugin-remove-duplicate-case": "^1.0.0",
|
|
125
127
|
"@putout/plugin-remove-duplicate-keys": "^2.0.0",
|
|
126
128
|
"@putout/plugin-remove-duplicates-from-logical-expressions": "^1.0.0",
|
|
127
|
-
"@putout/plugin-remove-empty": "^
|
|
129
|
+
"@putout/plugin-remove-empty": "^7.0.0",
|
|
128
130
|
"@putout/plugin-remove-iife": "^1.0.0",
|
|
129
131
|
"@putout/plugin-remove-nested-blocks": "^5.0.0",
|
|
130
132
|
"@putout/plugin-remove-unreachable-code": "^1.0.0",
|
|
@@ -158,7 +160,7 @@
|
|
|
158
160
|
"@putout/plugin-simplify-ternary": "^2.0.0",
|
|
159
161
|
"@putout/plugin-split-nested-destructuring": "^1.0.0",
|
|
160
162
|
"@putout/plugin-split-variable-declarations": "^2.0.0",
|
|
161
|
-
"@putout/plugin-strict-mode": "^
|
|
163
|
+
"@putout/plugin-strict-mode": "^3.0.0",
|
|
162
164
|
"@putout/plugin-tape": "^8.0.0",
|
|
163
165
|
"@putout/plugin-typescript": "^1.0.0",
|
|
164
166
|
"@putout/plugin-webpack": "^1.0.0",
|
|
@@ -166,7 +168,7 @@
|
|
|
166
168
|
"@putout/processor-ignore": "^2.0.0",
|
|
167
169
|
"@putout/processor-javascript": "^3.0.0",
|
|
168
170
|
"@putout/processor-json": "^3.0.0",
|
|
169
|
-
"@putout/processor-markdown": "^
|
|
171
|
+
"@putout/processor-markdown": "^6.0.0",
|
|
170
172
|
"@putout/processor-yaml": "^3.0.0",
|
|
171
173
|
"@putout/traverse": "^4.0.0",
|
|
172
174
|
"ajv": "^8.8.2",
|
|
@@ -219,11 +221,11 @@
|
|
|
219
221
|
"nodemon": "^2.0.1",
|
|
220
222
|
"pullout": "^4.0.0",
|
|
221
223
|
"strip-ansi": "^7.0.0",
|
|
222
|
-
"supertape": "^
|
|
224
|
+
"supertape": "^7.0.0"
|
|
223
225
|
},
|
|
224
226
|
"license": "MIT",
|
|
225
227
|
"engines": {
|
|
226
|
-
"node": ">=
|
|
228
|
+
"node": ">=16"
|
|
227
229
|
},
|
|
228
230
|
"publishConfig": {
|
|
229
231
|
"access": "public"
|