eslint-plugin-putout 19.3.0 β 19.5.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 +15 -19
- package/lib/no-unresolved/index.js +1 -0
- package/lib/putout/async/index.js +1 -0
- package/lib/putout/parse-error.js +5 -1
- package/lib/putout/sync/index.js +1 -0
- package/lib/remove-empty-newline-after-import/index.js +4 -4
- package/lib/remove-empty-newline-between-declarations/index.js +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -133,43 +133,24 @@ Disabled **ESLint** rules:
|
|
|
133
133
|
Disabled π**Putout** rules:
|
|
134
134
|
|
|
135
135
|
- β [`apply-template-literals`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-empty#readme);
|
|
136
|
-
|
|
137
136
|
- β [`remove-empty`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-empty#readme);
|
|
138
|
-
|
|
139
137
|
- β [`nodejs/remove-process-exit`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-nodejs#remove-process-exit#readme);
|
|
140
|
-
|
|
141
138
|
- β [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-variables#readme);
|
|
142
|
-
|
|
143
139
|
- β [`typescript/remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.2/packages/plugin-typescript#remove-unused-types#readme);
|
|
144
|
-
|
|
145
140
|
- β [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-expressions#readme);
|
|
146
|
-
|
|
147
141
|
- β [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreferenced-variables#readme);
|
|
148
|
-
|
|
149
142
|
- β [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-arguments#readme);
|
|
150
|
-
|
|
151
143
|
- β [`remove-useless-return`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-return#readme);
|
|
152
|
-
|
|
153
144
|
- β [`remove-useless-spread`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-spread/#readme);
|
|
154
|
-
|
|
155
145
|
- β [`remove-useless-variables/rename`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-variables#rename);
|
|
156
|
-
|
|
157
146
|
- β [`remove-skip`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-tape#remove-skip);
|
|
158
|
-
|
|
159
147
|
- β [`remove-only`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-tape#remove-only);
|
|
160
|
-
|
|
161
148
|
- β [`remove-console`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-console#readme);
|
|
162
|
-
|
|
163
149
|
- β [`remove-debugger`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-debugger#readme);
|
|
164
|
-
|
|
165
150
|
- β [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreachable-code#readme);
|
|
166
|
-
|
|
167
151
|
- β [`for-of/for`](https://github.com/coderaiser/putout/tree/v29.1.2/packages/plugin-convert-for-to-for-of#readme);
|
|
168
|
-
|
|
169
152
|
- β [`for-of/remove-useless`](https://github.com/coderaiser/putout/tree/v29.7.1/packages/plugin-for-of#remove-useless);
|
|
170
|
-
|
|
171
153
|
- β [`for-of/remove-unused-variables`](https://github.com/coderaiser/putout/tree/29.7.1/packages/plugin-for-of#remove-unused-variables);
|
|
172
|
-
|
|
173
154
|
- β [`maybe/noop`](https://github.com/coderaiser/putout/tree/29.2.4/packages/plugin-maybe#noop);
|
|
174
155
|
|
|
175
156
|
### safe+align
|
|
@@ -191,6 +172,21 @@ When you need to support `jsx` in files using `js` extension, use:
|
|
|
191
172
|
}
|
|
192
173
|
```
|
|
193
174
|
|
|
175
|
+
### esm
|
|
176
|
+
|
|
177
|
+
If you want to use **ESM** plugins of π**Putout** you need to use `esm` preset:
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"extends": [
|
|
182
|
+
"plugin:putout/esm"
|
|
183
|
+
],
|
|
184
|
+
"plugins": [
|
|
185
|
+
"putout"
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
194
190
|
## Flat
|
|
195
191
|
|
|
196
192
|
The time is came for a [FlatConfig](https://eslint.org/blog/2022/08/new-config-system-part-2/). To use it with `eslint-plugin-putout` add to `eslint.config.js`:
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
module.exports.parseError = ({message}) => {
|
|
3
|
+
module.exports.parseError = ({code, message, name}) => {
|
|
4
4
|
if (message.includes('buildError'))
|
|
5
5
|
return 'Parser error';
|
|
6
6
|
|
|
7
|
+
if (code === 'ERR_REQUIRE_ESM') {
|
|
8
|
+
return `βοΈ Looks like '${name}' is ESM, extend from 'plugin:putout/esm'`;
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
return message;
|
|
8
12
|
};
|
package/lib/putout/sync/index.js
CHANGED
|
@@ -25,10 +25,10 @@ module.exports = {
|
|
|
25
25
|
create(context) {
|
|
26
26
|
return {
|
|
27
27
|
ImportDeclaration(node) {
|
|
28
|
-
const
|
|
29
|
-
const text =
|
|
28
|
+
const {sourceCode} = context;
|
|
29
|
+
const text = sourceCode.getText(node);
|
|
30
30
|
|
|
31
|
-
const newline =
|
|
31
|
+
const newline = sourceCode
|
|
32
32
|
.getText(node, 0, 2)
|
|
33
33
|
.replace(text, '');
|
|
34
34
|
|
|
@@ -38,7 +38,7 @@ module.exports = {
|
|
|
38
38
|
if (newline !== '\n\n')
|
|
39
39
|
return;
|
|
40
40
|
|
|
41
|
-
const nextNode =
|
|
41
|
+
const nextNode = sourceCode.getNodeByRangeIndex(node.range[1] + 2);
|
|
42
42
|
|
|
43
43
|
if (!nextNode || nextNode.type !== 'ImportDeclaration')
|
|
44
44
|
return;
|
|
@@ -16,17 +16,17 @@ module.exports = {
|
|
|
16
16
|
create(context) {
|
|
17
17
|
return {
|
|
18
18
|
VariableDeclaration(node) {
|
|
19
|
-
const
|
|
20
|
-
const text =
|
|
19
|
+
const {sourceCode} = context;
|
|
20
|
+
const text = sourceCode.getText(node);
|
|
21
21
|
|
|
22
|
-
const newline =
|
|
22
|
+
const newline = sourceCode
|
|
23
23
|
.getText(node, 0, 2)
|
|
24
24
|
.replace(text, '');
|
|
25
25
|
|
|
26
26
|
if (newline !== '\n\n')
|
|
27
27
|
return;
|
|
28
28
|
|
|
29
|
-
const nextNode =
|
|
29
|
+
const nextNode = sourceCode.getNodeByRangeIndex(node.range[1] + 2);
|
|
30
30
|
|
|
31
31
|
if (!nextNode || nextNode.type !== 'VariableDeclaration')
|
|
32
32
|
return;
|
|
@@ -39,10 +39,10 @@ module.exports = {
|
|
|
39
39
|
if (nodeId.properties.length !== 1)
|
|
40
40
|
return;
|
|
41
41
|
|
|
42
|
-
const textId =
|
|
42
|
+
const textId = sourceCode.getText(nodeId.properties[0].value);
|
|
43
43
|
|
|
44
44
|
const nextNodeInit = nextNode.declarations[0].init;
|
|
45
|
-
const nextTextInit =
|
|
45
|
+
const nextTextInit = sourceCode.getText(nextNodeInit);
|
|
46
46
|
|
|
47
47
|
if (textId !== nextTextInit)
|
|
48
48
|
return;
|