putout 36.2.0 → 36.3.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 +12 -0
- package/lib/cli/process-file.js +1 -1
- package/lib/cli/runner/reader.js +1 -1
- package/lib/{cli/parse-error.js → parse-error.js} +2 -2
- package/lib/transform.js +24 -3
- package/package.json +3 -3
- package/putout.json +2 -3
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2024.08.25, v36.3.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- b519d78c8 putout: @putout/engine-loader v14.0.0
|
|
5
|
+
- 3bd6fbf36 putout: validationError: throw -> return in places
|
|
6
|
+
- 285b3e496 @putout/printer: validateRules: export and move out from loadPlugins
|
|
7
|
+
|
|
8
|
+
2024.08.24, v36.2.1
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- 44fa60e67 @putout/plugin-labels: add
|
|
12
|
+
|
|
1
13
|
2024.08.24, v36.2.0
|
|
2
14
|
|
|
3
15
|
fix:
|
package/lib/cli/process-file.js
CHANGED
|
@@ -8,7 +8,7 @@ const merge = require('../merge');
|
|
|
8
8
|
const parseMatch = require('../parse-options/parse-match');
|
|
9
9
|
|
|
10
10
|
const {simpleImport} = require('./simple-import');
|
|
11
|
-
const parseError = require('
|
|
11
|
+
const parseError = require('../parse-error');
|
|
12
12
|
|
|
13
13
|
const getMatchedOptions = (name, options) => {
|
|
14
14
|
if (!name.includes('{'))
|
package/lib/cli/runner/reader.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const tryToCatch = require('try-to-catch');
|
|
4
4
|
const {runProcessors} = require('@putout/engine-processor');
|
|
5
5
|
|
|
6
|
-
const parseError = require('
|
|
6
|
+
const parseError = require('../../parse-error.js');
|
|
7
7
|
const {simpleImport} = require('../simple-import');
|
|
8
8
|
const ignores = require('../../ignores.js');
|
|
9
9
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
module.exports = (e) => {
|
|
3
|
+
module.exports = (e, type = 'parser') => {
|
|
4
4
|
const {line, column} = e.loc || {
|
|
5
5
|
line: 1,
|
|
6
6
|
column: 1,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
const rule = e.rule ? `${e.rule} (parser)` :
|
|
9
|
+
const rule = e.rule ? `${e.rule} (parser)` : type;
|
|
10
10
|
const message = cutBrackets(e.message);
|
|
11
11
|
|
|
12
12
|
return [{
|
package/lib/transform.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const tryCatch = require('try-catch');
|
|
3
4
|
const {defaultOptions} = require('./default-options');
|
|
4
5
|
const {cutShebang} = require('./shebang');
|
|
6
|
+
const parseError = require('./parse-error');
|
|
7
|
+
const {validateRules} = require('@putout/engine-loader');
|
|
8
|
+
|
|
9
|
+
const maybeParseError = (a) => !a ? [] : parseError(a, 'loader');
|
|
5
10
|
|
|
6
11
|
// why we pass 'source' to 'transform()'?
|
|
7
12
|
// because we need to calculate position in a right way
|
|
8
|
-
// and determine is shebang is
|
|
13
|
+
// and determine is shebang is existing
|
|
9
14
|
//
|
|
10
15
|
// 25 return {¬
|
|
11
16
|
// 26 line: shebang ? line + 1 : line,¬
|
|
@@ -28,6 +33,11 @@ module.exports.transform = (ast, source, opts) => {
|
|
|
28
33
|
|
|
29
34
|
const [, shebang] = cutShebang(source);
|
|
30
35
|
|
|
36
|
+
const [validationError] = tryCatch(validateRules, {
|
|
37
|
+
rules,
|
|
38
|
+
pluginNames,
|
|
39
|
+
});
|
|
40
|
+
|
|
31
41
|
const plugins = loadPlugins({
|
|
32
42
|
pluginNames,
|
|
33
43
|
cache,
|
|
@@ -43,7 +53,10 @@ module.exports.transform = (ast, source, opts) => {
|
|
|
43
53
|
progress,
|
|
44
54
|
});
|
|
45
55
|
|
|
46
|
-
return
|
|
56
|
+
return [
|
|
57
|
+
...maybeParseError(validationError),
|
|
58
|
+
...places,
|
|
59
|
+
];
|
|
47
60
|
};
|
|
48
61
|
|
|
49
62
|
module.exports.transformAsync = async (ast, source, opts) => {
|
|
@@ -62,6 +75,11 @@ module.exports.transformAsync = async (ast, source, opts) => {
|
|
|
62
75
|
|
|
63
76
|
const [, shebang] = cutShebang(source);
|
|
64
77
|
|
|
78
|
+
const [validationError] = tryCatch(validateRules, {
|
|
79
|
+
rules,
|
|
80
|
+
pluginNames,
|
|
81
|
+
});
|
|
82
|
+
|
|
65
83
|
const plugins = await loadPluginsAsync({
|
|
66
84
|
pluginNames,
|
|
67
85
|
cache,
|
|
@@ -77,5 +95,8 @@ module.exports.transformAsync = async (ast, source, opts) => {
|
|
|
77
95
|
progress,
|
|
78
96
|
});
|
|
79
97
|
|
|
80
|
-
return
|
|
98
|
+
return [
|
|
99
|
+
...maybeParseError(validationError),
|
|
100
|
+
...places,
|
|
101
|
+
];
|
|
81
102
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.3.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",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@putout/cli-staged": "^1.0.0",
|
|
61
61
|
"@putout/cli-validate-args": "^2.0.0",
|
|
62
62
|
"@putout/compare": "^14.0.0",
|
|
63
|
-
"@putout/engine-loader": "^
|
|
63
|
+
"@putout/engine-loader": "^14.0.0",
|
|
64
64
|
"@putout/engine-parser": "^10.0.0",
|
|
65
65
|
"@putout/engine-processor": "^11.0.0",
|
|
66
66
|
"@putout/engine-reporter": "^1.0.0",
|
|
@@ -105,7 +105,6 @@
|
|
|
105
105
|
"@putout/plugin-convert-concat-to-flat": "^1.0.0",
|
|
106
106
|
"@putout/plugin-convert-const-to-let": "^3.0.0",
|
|
107
107
|
"@putout/plugin-convert-index-of-to-includes": "^2.0.0",
|
|
108
|
-
"@putout/plugin-convert-label-to-object": "^2.0.0",
|
|
109
108
|
"@putout/plugin-convert-object-assign-to-merge-spread": "^6.0.0",
|
|
110
109
|
"@putout/plugin-convert-object-entries-to-array-entries": "^3.0.0",
|
|
111
110
|
"@putout/plugin-convert-optional-to-logical": "^4.0.0",
|
|
@@ -125,6 +124,7 @@
|
|
|
125
124
|
"@putout/plugin-github": "^12.0.0",
|
|
126
125
|
"@putout/plugin-gitignore": "^6.0.0",
|
|
127
126
|
"@putout/plugin-group-imports-by-source": "^1.0.0",
|
|
127
|
+
"@putout/plugin-labels": "^1.0.0",
|
|
128
128
|
"@putout/plugin-logical-expressions": "^6.0.0",
|
|
129
129
|
"@putout/plugin-madrun": "^18.0.0",
|
|
130
130
|
"@putout/plugin-math": "^2.0.0",
|
package/putout.json
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"convert-quotes-to-backticks": "off",
|
|
54
54
|
"remove-unused-expressions": "off",
|
|
55
55
|
"remove-unused-variables": "off",
|
|
56
|
-
"remove-unused
|
|
56
|
+
"labels/remove-unused": "off",
|
|
57
57
|
"remove-useless-escape": "off",
|
|
58
58
|
"remove-useless-variables": "off",
|
|
59
59
|
"remove-useless-return": "off",
|
|
@@ -208,7 +208,6 @@
|
|
|
208
208
|
"remove-empty",
|
|
209
209
|
"remove-unreferenced-variables",
|
|
210
210
|
"remove-unused-variables",
|
|
211
|
-
"remove-unused-labels",
|
|
212
211
|
"remove-unused-private-fields",
|
|
213
212
|
"remove-unused-expressions",
|
|
214
213
|
"remove-useless-assign",
|
|
@@ -256,13 +255,13 @@
|
|
|
256
255
|
"convert-assignment-to-comparison",
|
|
257
256
|
"convert-quotes-to-backticks",
|
|
258
257
|
"convert-object-entries-to-array-entries",
|
|
259
|
-
"convert-label-to-object",
|
|
260
258
|
"merge-destructuring-properties",
|
|
261
259
|
"merge-duplicate-imports",
|
|
262
260
|
"merge-duplicate-functions",
|
|
263
261
|
"declare-imports-first",
|
|
264
262
|
"declare-before-reference",
|
|
265
263
|
"declare",
|
|
264
|
+
"labels",
|
|
266
265
|
"math",
|
|
267
266
|
"putout",
|
|
268
267
|
"putout-config",
|