eslint-plugin-putout 13.1.0 → 13.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
CHANGED
|
@@ -52,6 +52,7 @@ Then configure the rules you want to use under the rules section.
|
|
|
52
52
|
"putout/remove-newline-from-empty-object": "error",
|
|
53
53
|
"putout/remove-empty-newline-before-first-specifier": "error",
|
|
54
54
|
"putout/remove-empty-newline-after-last-specifier": "error",
|
|
55
|
+
"putout/remove-empty-specifiers": "error",
|
|
55
56
|
"putout/objects-braces-inside-array": "error",
|
|
56
57
|
"putout/object-init": "error"
|
|
57
58
|
}
|
|
@@ -79,6 +80,7 @@ Then configure the rules you want to use under the rules section.
|
|
|
79
80
|
- [Remove newline from empty object](/packages/eslint-plugin-putout/lib/remove-newline-from-empty-object)
|
|
80
81
|
- [Remove empty newline before first specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-before-first-specifier)
|
|
81
82
|
- [Remove empty newline after last specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-last-specifier)
|
|
83
|
+
- [Remove empty specifiers](/packages/eslint-plugin-putout/lib/remove-empty-specifiers)
|
|
82
84
|
- [Objects braces inside array](/packages/eslint-plugin-putout/lib/objects-braces-inside-array)
|
|
83
85
|
- [Object init](/packages/eslint-plugin-putout/lib/object-init)
|
|
84
86
|
- [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved)
|
|
@@ -101,10 +103,6 @@ When using 🐊`Putout` in IDE with `--fix` on save, or when you want to disable
|
|
|
101
103
|
}
|
|
102
104
|
```
|
|
103
105
|
|
|
104
|
-
### safe+align
|
|
105
|
-
|
|
106
|
-
When you want to enable ability to align spaces on empty lines, use `safe+align`.
|
|
107
|
-
|
|
108
106
|
Disabled `ESLint` rules:
|
|
109
107
|
|
|
110
108
|
- [`no-useless-return`](https://eslint.org/docs/rules/no-useless-return)
|
|
@@ -118,11 +116,18 @@ Disabled 🐊`Putout` rules:
|
|
|
118
116
|
- [`typescript/remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.2/packages/plugin-typescript#remove-unused-types);
|
|
119
117
|
- [`remove-unused-for-of-variables`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-unused-for-of-variables);
|
|
120
118
|
- [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v24.0.0/packages);
|
|
119
|
+
- [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/24.1.0/packages);
|
|
121
120
|
- [`remove-useless-return`](https://github.com/coderaiser/putout/tree/master/remove-useless-return);
|
|
122
121
|
- [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/remove-useless-arguments);
|
|
122
|
+
- [`remove-useless-variables/rename`](https://github.com/coderaiser/putout/tree/master/remove-useless-arguments#rename);
|
|
123
123
|
- [`remove-skip`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-skip);
|
|
124
124
|
- [`remove-only`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-only);
|
|
125
125
|
- [`remove-console`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-console);
|
|
126
126
|
- [`remove-debugger`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-debugger);
|
|
127
127
|
- [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-unreachable-code);
|
|
128
128
|
- [`convert-for-to-for-of`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/convert-for-to-for-of);
|
|
129
|
+
|
|
130
|
+
### safe+align
|
|
131
|
+
|
|
132
|
+
When you want to enable ability to align spaces on empty lines, while have all benefits of `safe` preset: use `safe+align`.
|
|
133
|
+
|
|
@@ -33,6 +33,9 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
|
|
|
33
33
|
|
|
34
34
|
const spaces = getSpacesBeforeNode(node, text);
|
|
35
35
|
|
|
36
|
+
if (!spaces)
|
|
37
|
+
return false;
|
|
38
|
+
|
|
36
39
|
if (regExp.test(spaces))
|
|
37
40
|
return false;
|
|
38
41
|
|
|
@@ -43,7 +46,6 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
|
|
|
43
46
|
continue;
|
|
44
47
|
|
|
45
48
|
const prevA = body[i - 1];
|
|
46
|
-
const nextA = body[i + 1];
|
|
47
49
|
|
|
48
50
|
if (!isVariableDeclaration(prevA))
|
|
49
51
|
return false;
|
|
@@ -53,11 +55,7 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
|
|
|
53
55
|
if (regExp.test(spaces))
|
|
54
56
|
return false;
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
return true;
|
|
58
|
-
|
|
59
|
-
const nextSpaces = getSpacesBeforeNode(nextA);
|
|
60
|
-
return !regExp.test(nextSpaces);
|
|
58
|
+
return true;
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
return false;
|
package/lib/index.js
CHANGED
|
@@ -33,6 +33,7 @@ module.exports.rules = {
|
|
|
33
33
|
...getWrapRule('remove-newline-from-empty-object'),
|
|
34
34
|
...getWrapRule('remove-empty-newline-before-first-specifier'),
|
|
35
35
|
...getWrapRule('remove-empty-newline-after-last-specifier'),
|
|
36
|
+
...getWrapRule('remove-empty-specifiers'),
|
|
36
37
|
...getWrapRule('objects-braces-inside-array'),
|
|
37
38
|
...getWrapRule('object-init'),
|
|
38
39
|
...getWrapRule('no-unresolved'),
|
|
@@ -70,6 +71,7 @@ const recommended = {
|
|
|
70
71
|
'putout/remove-newline-from-empty-object': 'error',
|
|
71
72
|
'putout/remove-empty-newline-before-first-specifier': 'error',
|
|
72
73
|
'putout/remove-empty-newline-after-last-specifier': 'error',
|
|
74
|
+
'putout/remove-empty-specifiers': 'error',
|
|
73
75
|
'putout/objects-braces-inside-array': 'error',
|
|
74
76
|
'putout/object-init': 'error',
|
|
75
77
|
'putout/no-unresolved': 'error',
|
|
@@ -111,6 +113,8 @@ const safe = {
|
|
|
111
113
|
'remove-unreachable-code': 'off',
|
|
112
114
|
'remove-useless-return': 'off',
|
|
113
115
|
'remove-useless-arguments': 'off',
|
|
116
|
+
'remove-useless-variables/rename': 'off',
|
|
117
|
+
'remove-unreferenced-variables': 'off',
|
|
114
118
|
'tape/remove-skip': 'off',
|
|
115
119
|
'tape/remove-only': 'off',
|
|
116
120
|
'remove-console': 'off',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Remove empty specifiers(`remove-empty-specifiers`)
|
|
2
|
+
|
|
3
|
+
## Rule Details
|
|
4
|
+
|
|
5
|
+
This rule aims to remove empty specifiers.
|
|
6
|
+
|
|
7
|
+
Examples of **incorrect** code for this rule:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import putout, {} from 'putout';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Examples of **correct** code for this rule:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import putout from 'putout';
|
|
17
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.category = 'object';
|
|
4
|
+
module.exports.report = () => 'Remove empty import specifiers';
|
|
5
|
+
|
|
6
|
+
module.exports.filter = ({text, node, getCommentsInside}) => {
|
|
7
|
+
const comments = getCommentsInside(node);
|
|
8
|
+
|
|
9
|
+
if (comments.length)
|
|
10
|
+
return false;
|
|
11
|
+
|
|
12
|
+
return text.includes('{}');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports.fix = ({text}) => {
|
|
16
|
+
return text
|
|
17
|
+
.replace('import {} from', 'import')
|
|
18
|
+
.replace(/,? {}/, '');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports.include = () => [
|
|
22
|
+
'ImportDeclaration',
|
|
23
|
+
];
|
|
24
|
+
|