putout 38.0.4 → 38.0.6
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 +14 -0
- package/lib/cli/runner/runner.js +2 -1
- package/lib/parse-options/apply-module-type-rules.js +3 -3
- package/lib/parse-options/index.js +6 -6
- package/lib/{merge.js → parse-options/merge-options.js} +1 -1
- package/lib/parse-options/parse-match.js +1 -1
- package/lib/parse-options/recursive-read.js +4 -4
- package/package.json +6 -4
- package/lib/cli/printer/printer.mjs +0 -61
- package/lib/cli/process-file.js +0 -95
package/ChangeLog
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
2025.02.04, v38.0.6
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 487a24e4e @putout/cli-process-file: add
|
|
5
|
+
- 34c38b881 @putout/plugin-extract-keywords-from-variables: MemberExpression
|
|
6
|
+
|
|
7
|
+
2025.02.03, v38.0.5
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- f4cc6a711 putout: @putout/plugin-putout-config v8.0.0
|
|
11
|
+
- ffeb3951a putout: @putout/plugin-esm v2.0.0
|
|
12
|
+
- a08863ef9 @putout/plugin-esm: drop support of 🐊 < 38
|
|
13
|
+
- 33e0c6129 @putout/plugin-esm: declare-imports-first: exclude not ESM
|
|
14
|
+
|
|
1
15
|
2025.02.02, v38.0.4
|
|
2
16
|
|
|
3
17
|
feature:
|
package/lib/cli/runner/runner.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Report = require('@putout/engine-reporter/report');
|
|
4
|
+
|
|
5
|
+
const initProcessFile = require('@putout/cli-process-file');
|
|
4
6
|
const {runWriter} = require('./writer.js');
|
|
5
|
-
const initProcessFile = require('../process-file.js');
|
|
6
7
|
|
|
7
8
|
const report = Report();
|
|
8
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const {mergeOptions} = require('./merge-options');
|
|
4
4
|
const {assign} = Object;
|
|
5
5
|
|
|
6
6
|
module.exports = ({type}, options) => {
|
|
7
|
-
const
|
|
8
|
-
assign(options,
|
|
7
|
+
const config = type === 'module' ? esm() : commonjs();
|
|
8
|
+
assign(options, mergeOptions(options, config));
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const commonjs = () => ({
|
|
@@ -10,9 +10,9 @@ const once = require('once');
|
|
|
10
10
|
const tryCatch = require('try-catch');
|
|
11
11
|
const escalade = require('escalade/sync');
|
|
12
12
|
|
|
13
|
-
const parseMatch = require('./parse-match');
|
|
13
|
+
const {parseMatch} = require('./parse-match');
|
|
14
14
|
const defaultOptions = require('../../putout.json');
|
|
15
|
-
const
|
|
15
|
+
const {mergeOptions} = require('./merge-options');
|
|
16
16
|
const recursiveRead = require('./recursive-read');
|
|
17
17
|
const applyModuleTypeRules = require('./apply-module-type-rules');
|
|
18
18
|
const {validateOptions} = require('./validate-options');
|
|
@@ -47,9 +47,9 @@ module.exports = (info = {}, overrides = {}) => {
|
|
|
47
47
|
options,
|
|
48
48
|
];
|
|
49
49
|
|
|
50
|
-
const mergedOptions =
|
|
50
|
+
const mergedOptions = mergeOptions(...optionsList);
|
|
51
51
|
|
|
52
|
-
const mergedDefaultsMatch =
|
|
52
|
+
const mergedDefaultsMatch = mergeOptions(
|
|
53
53
|
mergedOptions,
|
|
54
54
|
parseMatch(
|
|
55
55
|
name,
|
|
@@ -58,7 +58,7 @@ module.exports = (info = {}, overrides = {}) => {
|
|
|
58
58
|
options,
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
const mergedMatch =
|
|
61
|
+
const mergedMatch = mergeOptions(customOptions, options, parseMatch(name, options.match));
|
|
62
62
|
|
|
63
63
|
const resultOptionsList = [
|
|
64
64
|
readCodeMods({
|
|
@@ -74,7 +74,7 @@ module.exports = (info = {}, overrides = {}) => {
|
|
|
74
74
|
mergedMatch,
|
|
75
75
|
];
|
|
76
76
|
|
|
77
|
-
const finalMergedOptions =
|
|
77
|
+
const finalMergedOptions = mergeOptions(...resultOptionsList);
|
|
78
78
|
|
|
79
79
|
validateOptions(finalMergedOptions);
|
|
80
80
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const {dirname} = require('node:path');
|
|
4
4
|
const escalade = require('escalade/sync');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const parseMatch = require('./parse-match');
|
|
6
|
+
const {mergeOptions} = require('./merge-options');
|
|
7
|
+
const {parseMatch} = require('./parse-match');
|
|
8
8
|
|
|
9
9
|
module.exports = (name, configName, overrides) => {
|
|
10
10
|
if (name === '<input>')
|
|
@@ -19,10 +19,10 @@ module.exports = (name, configName, overrides) => {
|
|
|
19
19
|
customRequire,
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
let mergedOptions =
|
|
22
|
+
let mergedOptions = mergeOptions(...optionsList);
|
|
23
23
|
|
|
24
24
|
for (const currentOptions of optionsList)
|
|
25
|
-
mergedOptions =
|
|
25
|
+
mergedOptions = mergeOptions(
|
|
26
26
|
mergedOptions,
|
|
27
27
|
currentOptions,
|
|
28
28
|
parseMatch(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "38.0.
|
|
3
|
+
"version": "38.0.6",
|
|
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",
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
"require": "./lib/putout.js",
|
|
12
12
|
"import": "./lib/putout.mjs"
|
|
13
13
|
},
|
|
14
|
+
"./parse-error": "./lib/parse-error.js",
|
|
14
15
|
"./parse-options": "./lib/parse-options/index.js",
|
|
15
|
-
"./
|
|
16
|
+
"./parse-match": "./lib/parse-options/parse-match.js",
|
|
17
|
+
"./merge-options": "./lib/parse-options/merge-options.js",
|
|
16
18
|
"./exit-codes": "./lib/cli/exit-codes.mjs",
|
|
17
19
|
"./exit-codes/cjs": "./lib/cli/exit-codes.js",
|
|
18
20
|
"./cli": "./lib/cli/index.js",
|
|
@@ -54,6 +56,7 @@
|
|
|
54
56
|
"@putout/cli-choose-formatter": "^4.0.0",
|
|
55
57
|
"@putout/cli-keypress": "^2.0.0",
|
|
56
58
|
"@putout/cli-match": "^2.0.0",
|
|
59
|
+
"@putout/cli-process-file": "^1.0.0",
|
|
57
60
|
"@putout/cli-ruler": "^3.0.0",
|
|
58
61
|
"@putout/cli-staged": "^1.0.0",
|
|
59
62
|
"@putout/cli-validate-args": "^2.0.0",
|
|
@@ -139,7 +142,7 @@
|
|
|
139
142
|
"@putout/plugin-parens": "^1.0.0",
|
|
140
143
|
"@putout/plugin-promises": "^16.0.0",
|
|
141
144
|
"@putout/plugin-putout": "^23.0.0",
|
|
142
|
-
"@putout/plugin-putout-config": "^
|
|
145
|
+
"@putout/plugin-putout-config": "^8.0.0",
|
|
143
146
|
"@putout/plugin-regexp": "^9.0.0",
|
|
144
147
|
"@putout/plugin-remove-console": "^6.0.0",
|
|
145
148
|
"@putout/plugin-remove-constant-conditions": "^4.0.0",
|
|
@@ -207,7 +210,6 @@
|
|
|
207
210
|
"nano-memoize": "^3.0.11",
|
|
208
211
|
"once": "^1.4.0",
|
|
209
212
|
"picomatch": "^4.0.2",
|
|
210
|
-
"samadhi": "^2.10.0",
|
|
211
213
|
"try-catch": "^3.0.0",
|
|
212
214
|
"try-to-catch": "^3.0.0",
|
|
213
215
|
"wraptile": "^3.0.0",
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import deepMerge from 'deepmerge';
|
|
2
|
-
|
|
3
|
-
const {isArray} = Array;
|
|
4
|
-
const maybeArray = (a) => isArray(a) ? a : [a];
|
|
5
|
-
|
|
6
|
-
const DefaultMarkdown = {
|
|
7
|
-
format: {
|
|
8
|
-
endOfFile: '',
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const JSON = {
|
|
13
|
-
format: {
|
|
14
|
-
quote: '"',
|
|
15
|
-
},
|
|
16
|
-
semantics: {
|
|
17
|
-
trailingComma: false,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const configurePrinter = (name, printerOptions) => {
|
|
22
|
-
const [printer = 'putout', options = {}] = maybeArray(printerOptions);
|
|
23
|
-
const ext = name
|
|
24
|
-
.split('.')
|
|
25
|
-
.pop();
|
|
26
|
-
|
|
27
|
-
if (printer !== 'putout')
|
|
28
|
-
return printerOptions;
|
|
29
|
-
|
|
30
|
-
const mergedOptions = deepMerge(parseOptions(ext), options);
|
|
31
|
-
|
|
32
|
-
return [printer, mergedOptions];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
function parseOptions(ext) {
|
|
36
|
-
if (ext === 'json')
|
|
37
|
-
return JSON;
|
|
38
|
-
|
|
39
|
-
if (ext === 'yml{json}')
|
|
40
|
-
return JSON;
|
|
41
|
-
|
|
42
|
-
if (ext === 'md{json}')
|
|
43
|
-
return {
|
|
44
|
-
format: {
|
|
45
|
-
...DefaultMarkdown.format,
|
|
46
|
-
...JSON.format,
|
|
47
|
-
},
|
|
48
|
-
semantics: {
|
|
49
|
-
...DefaultMarkdown.semantics,
|
|
50
|
-
...JSON.semantics,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
if (ext === 'md{js}')
|
|
55
|
-
return DefaultMarkdown;
|
|
56
|
-
|
|
57
|
-
if (ext === 'md{ts}')
|
|
58
|
-
return DefaultMarkdown;
|
|
59
|
-
|
|
60
|
-
return {};
|
|
61
|
-
}
|
package/lib/cli/process-file.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const tryToCatch = require('try-to-catch');
|
|
4
|
-
const eslint = require('@putout/eslint');
|
|
5
|
-
|
|
6
|
-
const {putoutAsync} = require('../..');
|
|
7
|
-
const merge = require('../merge');
|
|
8
|
-
const parseMatch = require('../parse-options/parse-match');
|
|
9
|
-
|
|
10
|
-
const {simpleImport} = require('./simple-import');
|
|
11
|
-
const parseError = require('../parse-error');
|
|
12
|
-
|
|
13
|
-
const getMatchedOptions = (name, options) => {
|
|
14
|
-
if (!name.includes('{'))
|
|
15
|
-
return options;
|
|
16
|
-
|
|
17
|
-
return merge(options, parseMatch(name, options.match));
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
module.exports = ({fix, fixCount, isFlow, logError, raw}) => async function processFile({name, source, startLine, options, again}) {
|
|
21
|
-
const {configurePrinter} = await import('./printer/printer.mjs');
|
|
22
|
-
const isTS = /\.tsx?$/.test(name) || /{tsx?}$/.test(name);
|
|
23
|
-
const {printer, ...matchedOptions} = getMatchedOptions(name, options);
|
|
24
|
-
|
|
25
|
-
const [e, result] = await tryToCatch(putoutAsync, source, {
|
|
26
|
-
fix,
|
|
27
|
-
fixCount,
|
|
28
|
-
isTS,
|
|
29
|
-
isFlow,
|
|
30
|
-
...matchedOptions,
|
|
31
|
-
printer: configurePrinter(name, printer),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (!again && e) {
|
|
35
|
-
raw && logError(e);
|
|
36
|
-
|
|
37
|
-
const {lint} = await simpleImport('samadhi');
|
|
38
|
-
const [code, places] = await lint(source, {
|
|
39
|
-
startLine,
|
|
40
|
-
fix,
|
|
41
|
-
isTS,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
if (!fix && places.length)
|
|
45
|
-
return {
|
|
46
|
-
code,
|
|
47
|
-
places,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
if (fix && !places.length)
|
|
51
|
-
return await processFile({
|
|
52
|
-
again: true,
|
|
53
|
-
name,
|
|
54
|
-
source: code,
|
|
55
|
-
startLine,
|
|
56
|
-
options,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const {code = source} = result || {};
|
|
61
|
-
const allPlaces = result ? result.places : parseError(e);
|
|
62
|
-
|
|
63
|
-
const [newCode, newPlaces] = await eslint({
|
|
64
|
-
name,
|
|
65
|
-
code,
|
|
66
|
-
fix,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
allPlaces.push(...newPlaces);
|
|
70
|
-
|
|
71
|
-
const places = formatPlaces(startLine, allPlaces);
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
places,
|
|
75
|
-
code: newCode,
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
function formatPlaces(line = 1, places) {
|
|
80
|
-
const newPlaces = [];
|
|
81
|
-
|
|
82
|
-
for (const place of places) {
|
|
83
|
-
const {position} = place;
|
|
84
|
-
|
|
85
|
-
newPlaces.push({
|
|
86
|
-
...place,
|
|
87
|
-
position: {
|
|
88
|
-
...position,
|
|
89
|
-
line: line + position.line,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return newPlaces;
|
|
95
|
-
}
|