putout 35.16.2 → 35.18.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 +20 -0
- package/lib/cli/get-files.js +2 -2
- package/lib/cli/get-options.js +2 -2
- package/lib/cli/index.js +1 -1
- package/lib/cli/process-file.js +14 -2
- package/lib/cli/runner/writer.js +3 -3
- package/lib/cli/supported-files.js +1 -1
- package/lib/ignores.js +1 -1
- package/lib/parse-options/index.js +29 -38
- package/lib/parse-options/parse-sep.js +1 -1
- package/lib/parse-options/read-rules.js +44 -0
- package/lib/parse-options/recursive-read.js +1 -1
- package/package.json +2 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
2024.04.29, v35.18.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 94b8e8908 putout: parse-options: rulesdir: exclude *.md
|
|
5
|
+
- 2a817e8a5 @putout/operate: insertAfter: wrap ExpressionStatement when current path is Statement and node not
|
|
6
|
+
|
|
7
|
+
2024.04.28, v35.17.0
|
|
8
|
+
|
|
9
|
+
fix:
|
|
10
|
+
- a87e7e06c @putout/plugin-nodejs: add-node-predynamic: Identifier
|
|
11
|
+
- ca542fb12 @putout/eslint: no config found: Flat Config error -> RC error
|
|
12
|
+
|
|
13
|
+
feature:
|
|
14
|
+
- 9f76b2a51 putout: @putout/quick-lint v1.0.0
|
|
15
|
+
- 8ad6cd673 @putout/eslint: add ability to hande no FlatConfig found error
|
|
16
|
+
- 949e898c9 @putout/plugin-nodejs: add-node-prefix: simplify
|
|
17
|
+
- 1551e9f04 @putout/plugin-nodejs: add-node-prefix: dynamic import
|
|
18
|
+
- 08acf9555 @putout/plugin-nodejs: add-node-prefix: add require
|
|
19
|
+
- 6744c616f @putout/plugin-nodejs: add-node-prefix: report
|
|
20
|
+
|
|
1
21
|
2024.04.26, v35.16.2
|
|
2
22
|
|
|
3
23
|
feature:
|
package/lib/cli/get-files.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {normalize} = require('path');
|
|
4
|
-
const {lstat} = require('fs/promises');
|
|
3
|
+
const {normalize} = require('node:path');
|
|
4
|
+
const {lstat} = require('node:fs/promises');
|
|
5
5
|
|
|
6
6
|
const fastGlob = require('fast-glob');
|
|
7
7
|
const tryToCatch = require('try-to-catch');
|
package/lib/cli/get-options.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const process = require('process');
|
|
4
|
-
const {join, dirname} = require('path');
|
|
3
|
+
const process = require('node:process');
|
|
4
|
+
const {join, dirname} = require('node:path');
|
|
5
5
|
|
|
6
6
|
const buildPlugins = require('./build-plugins');
|
|
7
7
|
const parseOptions = require('../parse-options');
|
package/lib/cli/index.js
CHANGED
package/lib/cli/process-file.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const tryToCatch = require('try-to-catch');
|
|
4
|
+
const eslint = require('@putout/eslint');
|
|
5
|
+
const quickLint = require('@putout/quick-lint');
|
|
4
6
|
|
|
5
7
|
const {putoutAsync} = require('../..');
|
|
6
8
|
const merge = require('../merge');
|
|
7
9
|
const parseMatch = require('../parse-options/parse-match');
|
|
8
10
|
|
|
9
|
-
const eslint = require('@putout/eslint');
|
|
10
11
|
const parseError = require('./parse-error');
|
|
11
12
|
|
|
12
13
|
const getMatchedOptions = (name, options) => {
|
|
@@ -30,8 +31,19 @@ module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async ({na
|
|
|
30
31
|
printer: configurePrinter(name, printer),
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
if (e)
|
|
34
|
+
if (e) {
|
|
34
35
|
raw && logError(e);
|
|
36
|
+
const quickLintPlaces = await quickLint(source, {
|
|
37
|
+
isTS,
|
|
38
|
+
isJSX: true,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (quickLintPlaces.length)
|
|
42
|
+
return {
|
|
43
|
+
places: quickLintPlaces,
|
|
44
|
+
code: source,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
35
47
|
|
|
36
48
|
const {code = source} = result || {};
|
|
37
49
|
const allPlaces = result ? result.places : parseError(e);
|
package/lib/cli/runner/writer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {resolve} = require('path');
|
|
4
|
-
const {cwd, env} = require('process');
|
|
5
|
-
const {readFileSync} = require('fs');
|
|
3
|
+
const {resolve} = require('node:path');
|
|
4
|
+
const {cwd, env} = require('node:process');
|
|
5
|
+
const {readFileSync} = require('node:fs');
|
|
6
6
|
|
|
7
7
|
const tryCatch = require('try-catch');
|
|
8
8
|
const getOptions = require('../get-options.js');
|
package/lib/ignores.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const process = require('process');
|
|
4
|
-
const {homedir} = require('os');
|
|
5
|
-
const {readdirSync} = require('fs');
|
|
3
|
+
const process = require('node:process');
|
|
4
|
+
const {homedir} = require('node:os');
|
|
5
|
+
const {readdirSync: _readdirSync} = require('node:fs');
|
|
6
6
|
|
|
7
|
-
const {dirname, join} = require('path');
|
|
7
|
+
const {dirname, join} = require('node:path');
|
|
8
8
|
|
|
9
9
|
const once = require('once');
|
|
10
10
|
const tryCatch = require('try-catch');
|
|
@@ -16,10 +16,11 @@ const merge = require('../merge');
|
|
|
16
16
|
const recursiveRead = require('./recursive-read');
|
|
17
17
|
const applyModuleTypeRules = require('./apply-module-type-rules');
|
|
18
18
|
const {validateOptions} = require('./validate-options');
|
|
19
|
+
const {readRules} = require('./read-rules');
|
|
19
20
|
|
|
20
21
|
const home = homedir();
|
|
21
22
|
|
|
22
|
-
module.exports = (info = {}) => {
|
|
23
|
+
module.exports = (info = {}, overrides = {}) => {
|
|
23
24
|
const {
|
|
24
25
|
rulesdir,
|
|
25
26
|
name = '',
|
|
@@ -29,6 +30,8 @@ module.exports = (info = {}) => {
|
|
|
29
30
|
readCodeMods = _readCodeMods,
|
|
30
31
|
} = info;
|
|
31
32
|
|
|
33
|
+
const {cwd = process.cwd(), readdirSync = _readdirSync} = overrides;
|
|
34
|
+
|
|
32
35
|
const [dir, customOptions] = readOptions(name);
|
|
33
36
|
const homeOptions = readHomeOptions();
|
|
34
37
|
const defaultMatch = parseMatch(name, defaultOptions.match);
|
|
@@ -54,12 +57,26 @@ module.exports = (info = {}) => {
|
|
|
54
57
|
|
|
55
58
|
const mergedMatch = merge(customOptions, options, parseMatch(name, options.match));
|
|
56
59
|
|
|
57
|
-
const
|
|
60
|
+
const resultOptionsList = [
|
|
61
|
+
readCodeMods({
|
|
62
|
+
cwd,
|
|
63
|
+
readdirSync,
|
|
64
|
+
}),
|
|
65
|
+
readRules('./', rulesdir, {
|
|
66
|
+
cwd,
|
|
67
|
+
readdirSync,
|
|
68
|
+
}),
|
|
69
|
+
mergedOptions,
|
|
70
|
+
mergedDefaultsMatch,
|
|
71
|
+
mergedMatch,
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const finalMergedOptions = merge(...resultOptionsList);
|
|
58
75
|
|
|
59
|
-
validateOptions(
|
|
76
|
+
validateOptions(finalMergedOptions);
|
|
60
77
|
|
|
61
78
|
return {
|
|
62
|
-
...
|
|
79
|
+
...finalMergedOptions,
|
|
63
80
|
dir,
|
|
64
81
|
};
|
|
65
82
|
};
|
|
@@ -86,35 +103,6 @@ function _readOptions(name) {
|
|
|
86
103
|
return ['', {}];
|
|
87
104
|
}
|
|
88
105
|
|
|
89
|
-
const isInclude = (a) => a[0] !== '.' && !/(^not-rule-.*|^node_modules$)/.test(a);
|
|
90
|
-
|
|
91
|
-
function readRules(dirOpt, rulesDir) {
|
|
92
|
-
if (!rulesDir)
|
|
93
|
-
return {};
|
|
94
|
-
|
|
95
|
-
let dir = join(dirOpt, rulesDir);
|
|
96
|
-
|
|
97
|
-
if (!dir.startsWith('/'))
|
|
98
|
-
dir = join(process.cwd(), rulesDir);
|
|
99
|
-
|
|
100
|
-
const [e, names] = tryCatch(readdirSync, dir);
|
|
101
|
-
|
|
102
|
-
if (e)
|
|
103
|
-
return {};
|
|
104
|
-
|
|
105
|
-
const plugins = [];
|
|
106
|
-
|
|
107
|
-
for (const name of names.filter(isInclude)) {
|
|
108
|
-
const full = join(dir, name);
|
|
109
|
-
|
|
110
|
-
plugins.push(`import:${full}`);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
plugins,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
106
|
const _readHomeOptions = once(() => {
|
|
119
107
|
const name = join(home, '.putout.json');
|
|
120
108
|
const [, data = {}] = tryCatch(require, name);
|
|
@@ -122,4 +110,7 @@ const _readHomeOptions = once(() => {
|
|
|
122
110
|
return data;
|
|
123
111
|
});
|
|
124
112
|
|
|
125
|
-
const _readCodeMods = once(() => readRules(home, '.putout'
|
|
113
|
+
const _readCodeMods = once(({cwd, readdirSync}) => readRules(home, '.putout', {
|
|
114
|
+
cwd,
|
|
115
|
+
readdirSync,
|
|
116
|
+
}));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {join} = require('node:path');
|
|
4
|
+
|
|
5
|
+
const tryCatch = require('try-catch');
|
|
6
|
+
|
|
7
|
+
const isInclude = (a) => {
|
|
8
|
+
if (a[0] === '.')
|
|
9
|
+
return false;
|
|
10
|
+
|
|
11
|
+
if (/(^not-rule-.*|^node_modules$)/.test(a))
|
|
12
|
+
return false;
|
|
13
|
+
|
|
14
|
+
return !a.endsWith('.md');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports.readRules = (dirOpt, rulesDir, overrides) => {
|
|
18
|
+
if (!rulesDir)
|
|
19
|
+
return {};
|
|
20
|
+
|
|
21
|
+
const {cwd, readdirSync} = overrides;
|
|
22
|
+
|
|
23
|
+
let dir = join(dirOpt, rulesDir);
|
|
24
|
+
|
|
25
|
+
if (!dir.startsWith('/'))
|
|
26
|
+
dir = join(cwd, rulesDir);
|
|
27
|
+
|
|
28
|
+
const [e, names] = tryCatch(readdirSync, dir);
|
|
29
|
+
|
|
30
|
+
if (e)
|
|
31
|
+
return {};
|
|
32
|
+
|
|
33
|
+
const plugins = [];
|
|
34
|
+
|
|
35
|
+
for (const name of names.filter(isInclude)) {
|
|
36
|
+
const full = join(dir, name);
|
|
37
|
+
|
|
38
|
+
plugins.push(`import:${full}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
plugins,
|
|
43
|
+
};
|
|
44
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "35.
|
|
3
|
+
"version": "35.18.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",
|
|
@@ -185,6 +185,7 @@
|
|
|
185
185
|
"@putout/processor-json": "^9.0.0",
|
|
186
186
|
"@putout/processor-markdown": "^12.0.0",
|
|
187
187
|
"@putout/processor-yaml": "^8.0.0",
|
|
188
|
+
"@putout/quick-lint": "^1.0.0",
|
|
188
189
|
"@putout/traverse": "^10.0.0",
|
|
189
190
|
"ajv": "^8.8.2",
|
|
190
191
|
"chalk": "^5.3.0",
|