eslint-plugin-putout 13.2.0 → 13.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/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)
|
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',
|
|
@@ -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
|
+
|