eslint-plugin-putout 14.5.0 → 14.6.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/README.md +18 -18
- package/lib/putout/index.js +11 -2
- 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
|
@@ -58,6 +58,9 @@ module.exports = {
|
|
|
58
58
|
parser: createParser(node),
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
// remove parent nodes that was ignored before converting to babel
|
|
62
|
+
removeParent(ast);
|
|
63
|
+
|
|
61
64
|
const [error, places = []] = tryCatch(findPlaces, ast, text, resultOptions);
|
|
62
65
|
|
|
63
66
|
if (error)
|
|
@@ -97,14 +100,20 @@ const fix = ({ast, text, node, source, resultOptions}) => (fixer) => {
|
|
|
97
100
|
|
|
98
101
|
const [, last] = lastToken.range;
|
|
99
102
|
|
|
100
|
-
removeParent(ast);
|
|
101
103
|
const code = print(ast);
|
|
102
104
|
|
|
103
105
|
return fixer.replaceTextRange([0, last], code);
|
|
104
106
|
};
|
|
105
107
|
|
|
108
|
+
// 1. We cannot modify ESLint AST
|
|
109
|
+
// 2. Parent nodes makes Recast go crazy, so they should be removed
|
|
110
|
+
// 3. Recast creates original nodes with copies of each nodes
|
|
111
|
+
// 4. Parser does nothing but returns original AST before estree to babel
|
|
112
|
+
// 5. All this stuff made to gain performance benefit of avoiding a duble parsing: ESLint, and then Babel
|
|
113
|
+
// 6. Always can be removed and switched to direct parsing by Putout, when benefits outweight supporting all of this magic
|
|
106
114
|
const createParser = (node) => {
|
|
107
115
|
const ast = copyAST(node);
|
|
116
|
+
removeParent(ast);
|
|
108
117
|
|
|
109
118
|
const parser = {
|
|
110
119
|
parse: returns(ast),
|
|
@@ -115,7 +124,7 @@ const createParser = (node) => {
|
|
|
115
124
|
|
|
116
125
|
// ESLint adds parent to each node
|
|
117
126
|
// it makes recase go crazy
|
|
118
|
-
// so we better drop them
|
|
127
|
+
// so we better drop them out
|
|
119
128
|
//
|
|
120
129
|
// https://github.com/eslint/eslint/blob/v8.4.0/lib/linter/linter.js#L964
|
|
121
130
|
function removeParent(ast) {
|
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.6.0",
|
|
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",
|