eslint-plugin-putout 14.5.0 → 14.7.1
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/README.md +18 -18
- package/lib/putout/index.js +15 -35
- package/lib/remove-empty-newline-after-import/index.js +1 -0
- package/lib/ts.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -132,24 +132,24 @@ Disabled **ESLint** rules:
|
|
|
132
132
|
|
|
133
133
|
Disabled 🐊**Putout** rules:
|
|
134
134
|
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
-
|
|
135
|
+
- ✅ [`remove-empty`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-empty#readme);
|
|
136
|
+
- ✅ [`nodejs/remove-process-exit`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-nodejs#remove-process-exit#readme);
|
|
137
|
+
- ✅ [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-unused-variables#readme);
|
|
138
|
+
- ✅ [`typescript/remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.2/packages/plugin-typescript#remove-unused-types#readme);
|
|
139
|
+
- ✅ [`remove-unused-for-of-variables`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-unused-for-of-variables#readme);
|
|
140
|
+
- ✅ [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-removeunused-expressions#readme);
|
|
141
|
+
- ✅ [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/24.1.0/packages/plugin-remove-unreferenced-variables#readme);
|
|
142
|
+
- ✅ [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-arguments#readme);
|
|
143
|
+
- ✅ [`remove-useless-for-of`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-for-of#readme);
|
|
144
|
+
- ✅ [`remove-useless-return`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-return#readme);
|
|
145
|
+
- ✅ [`remove-useless-spread`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-spread/#readme#readme);
|
|
146
|
+
- ✅ [`remove-useless-variables/rename`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-arguments#rename#readme);
|
|
147
|
+
- ✅ [`remove-skip`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-tape#remove-skip);
|
|
148
|
+
- ✅ [`remove-only`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-tape#remove-only);
|
|
149
|
+
- ✅ [`remove-console`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-console#readme);
|
|
150
|
+
- ✅ [`remove-debugger`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-debugger#readme);
|
|
151
|
+
- ✅ [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-unreachable-code#readme);
|
|
152
|
+
- ✅ [`convert-for-to-for-of`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-convert-for-to-for-of#readme);
|
|
153
153
|
|
|
154
154
|
### safe+align
|
|
155
155
|
|
package/lib/putout/index.js
CHANGED
|
@@ -10,10 +10,6 @@ const {
|
|
|
10
10
|
parse,
|
|
11
11
|
} = require('putout');
|
|
12
12
|
|
|
13
|
-
const traverse = require('@babel/traverse').default;
|
|
14
|
-
|
|
15
|
-
const v8 = require('v8');
|
|
16
|
-
|
|
17
13
|
const parseOptions = require('putout/parse-options');
|
|
18
14
|
const {parseError} = require('./parse-error');
|
|
19
15
|
|
|
@@ -23,9 +19,6 @@ const getContextOptions = ({options}) => {
|
|
|
23
19
|
return allContextOptions;
|
|
24
20
|
};
|
|
25
21
|
|
|
26
|
-
const copyAST = (a) => v8.deserialize(v8.serialize(a));
|
|
27
|
-
const returns = (a) => () => a;
|
|
28
|
-
|
|
29
22
|
const EMPTY_VISITORS = {};
|
|
30
23
|
|
|
31
24
|
module.exports = {
|
|
@@ -54,17 +47,29 @@ module.exports = {
|
|
|
54
47
|
const {text} = source;
|
|
55
48
|
const node = source.ast;
|
|
56
49
|
|
|
57
|
-
const ast = parse
|
|
58
|
-
|
|
50
|
+
const [errorParser, ast] = tryCatch(parse, text, {
|
|
51
|
+
isTS: true,
|
|
59
52
|
});
|
|
60
53
|
|
|
54
|
+
if (errorParser) {
|
|
55
|
+
context.report({
|
|
56
|
+
message: `${parseError(errorParser)} (putout)`,
|
|
57
|
+
node,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return EMPTY_VISITORS;
|
|
61
|
+
}
|
|
62
|
+
|
|
61
63
|
const [error, places = []] = tryCatch(findPlaces, ast, text, resultOptions);
|
|
62
64
|
|
|
63
|
-
if (error)
|
|
65
|
+
if (error) {
|
|
64
66
|
context.report({
|
|
65
67
|
message: `${parseError(error)} (putout)`,
|
|
66
68
|
node,
|
|
67
69
|
});
|
|
70
|
+
|
|
71
|
+
return EMPTY_VISITORS;
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
for (const {rule, message, position} of places) {
|
|
70
75
|
context.report({
|
|
@@ -97,33 +102,8 @@ const fix = ({ast, text, node, source, resultOptions}) => (fixer) => {
|
|
|
97
102
|
|
|
98
103
|
const [, last] = lastToken.range;
|
|
99
104
|
|
|
100
|
-
removeParent(ast);
|
|
101
105
|
const code = print(ast);
|
|
102
106
|
|
|
103
107
|
return fixer.replaceTextRange([0, last], code);
|
|
104
108
|
};
|
|
105
109
|
|
|
106
|
-
const createParser = (node) => {
|
|
107
|
-
const ast = copyAST(node);
|
|
108
|
-
|
|
109
|
-
const parser = {
|
|
110
|
-
parse: returns(ast),
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
return parser;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// ESLint adds parent to each node
|
|
117
|
-
// it makes recase go crazy
|
|
118
|
-
// so we better drop them
|
|
119
|
-
//
|
|
120
|
-
// https://github.com/eslint/eslint/blob/v8.4.0/lib/linter/linter.js#L964
|
|
121
|
-
function removeParent(ast) {
|
|
122
|
-
traverse(ast, {
|
|
123
|
-
noScope: true,
|
|
124
|
-
enter(path) {
|
|
125
|
-
delete path.node.parent;
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
package/lib/ts.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.7.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "eslint plugin for putout",
|
|
6
6
|
"release": false,
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@putout/test": "^5.0.0",
|
|
53
53
|
"c8": "^7.5.0",
|
|
54
54
|
"eslint": "^8.0.1",
|
|
55
|
-
"eslint-plugin-eslint-plugin": "^
|
|
55
|
+
"eslint-plugin-eslint-plugin": "^4.1.0",
|
|
56
56
|
"madrun": "^9.0.0",
|
|
57
57
|
"mocha": "^9.0.1",
|
|
58
58
|
"montag": "^1.0.0",
|