putout 38.0.5 → 38.0.7
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 +20 -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,23 @@
|
|
|
1
|
+
2025.02.05, v38.0.7
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- da369e6e6 @putout/operator-keyword: typescript
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- a56fdafa3 putout: @putout/plugin-apply-template-literals v4.0.0
|
|
8
|
+
- 99b7bc6e7 @putout/plugin-apply-template-literals: exclude \n
|
|
9
|
+
- 2b5274a3f @putout/plugin-apply-template-literals: drop support of 🐊 < 38
|
|
10
|
+
- 61065dc79 @putout/operator-keyword: interface
|
|
11
|
+
- eb86fd19d @putout/engine-loader: async-loader: require.resolve
|
|
12
|
+
- 7e6560416 @putout/engine-loader: async-loader: PUTOUT_LOAD_DIR
|
|
13
|
+
- b17d5145f @putout/processor-markdown: add support frontmatter
|
|
14
|
+
|
|
15
|
+
2025.02.04, v38.0.6
|
|
16
|
+
|
|
17
|
+
feature:
|
|
18
|
+
- 487a24e4e @putout/cli-process-file: add
|
|
19
|
+
- 34c38b881 @putout/plugin-extract-keywords-from-variables: MemberExpression
|
|
20
|
+
|
|
1
21
|
2025.02.03, v38.0.5
|
|
2
22
|
|
|
3
23
|
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.7",
|
|
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",
|
|
@@ -92,7 +95,7 @@
|
|
|
92
95
|
"@putout/plugin-apply-overrides": "^2.0.0",
|
|
93
96
|
"@putout/plugin-apply-shorthand-properties": "^6.0.0",
|
|
94
97
|
"@putout/plugin-apply-starts-with": "^1.0.0",
|
|
95
|
-
"@putout/plugin-apply-template-literals": "^
|
|
98
|
+
"@putout/plugin-apply-template-literals": "^4.0.0",
|
|
96
99
|
"@putout/plugin-browserlist": "^2.0.0",
|
|
97
100
|
"@putout/plugin-conditions": "^7.0.0",
|
|
98
101
|
"@putout/plugin-convert-apply-to-spread": "^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
|
-
}
|