eslint-plugin-putout 14.11.0 → 14.12.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
|
@@ -36,6 +36,7 @@ Then configure the rules you want to use under the rules section.
|
|
|
36
36
|
{
|
|
37
37
|
"rules": {
|
|
38
38
|
"putout/add-newlines-between-types-in-union": "error",
|
|
39
|
+
"putout/add-newlines-between-specifiers": "error",
|
|
39
40
|
"putout/add-newline-before-function-call": "error",
|
|
40
41
|
"putout/add-newline-after-function-call": "error",
|
|
41
42
|
"putout/putout": "error",
|
|
@@ -85,6 +86,7 @@ Then configure the rules you want to use under the rules section.
|
|
|
85
86
|
|
|
86
87
|
- ✅ [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved#readme)
|
|
87
88
|
- ✅ [Remove duplicate extension](/packages/eslint-plugin-putout/lib/remove-duplicate-extensions#readme)
|
|
89
|
+
- ✅ [Add newlines between specifiers](/packages/eslint-plugin-putout/lib/add-newlines-between-specifiers#readme)
|
|
88
90
|
|
|
89
91
|
### Formatting
|
|
90
92
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# add-newlines-between-specifiers
|
|
2
|
+
|
|
3
|
+
This rule aims to add newlines between specifiers.
|
|
4
|
+
|
|
5
|
+
## ❌ Example of incorrect code
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
let a;
|
|
9
|
+
let b;
|
|
10
|
+
let c;
|
|
11
|
+
let d;
|
|
12
|
+
let e;
|
|
13
|
+
let f;
|
|
14
|
+
|
|
15
|
+
export {a, b, c, d, e, f};
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## ✅ Example of correct code
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
let a;
|
|
22
|
+
let b;
|
|
23
|
+
let c;
|
|
24
|
+
let d;
|
|
25
|
+
let e;
|
|
26
|
+
let f;
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
a,
|
|
30
|
+
b,
|
|
31
|
+
c,
|
|
32
|
+
d,
|
|
33
|
+
e,
|
|
34
|
+
f,
|
|
35
|
+
};
|
|
36
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const regExp = /, +?[A-z]/g;
|
|
4
|
+
|
|
5
|
+
module.exports.category = 'layout';
|
|
6
|
+
module.exports.report = () => 'Add newlines between specifiers';
|
|
7
|
+
|
|
8
|
+
module.exports.include = () => [
|
|
9
|
+
'ExportNamedDeclaration',
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
module.exports.fix = ({text}) => {
|
|
13
|
+
return text
|
|
14
|
+
.replace(/,\s+/g, ',\n ')
|
|
15
|
+
.replace(/{/g, '{\n')
|
|
16
|
+
.replace(/}/g, '\n}')
|
|
17
|
+
.replace(/{\n+/g, '{\n')
|
|
18
|
+
.replace(/\n+}/g, '\n}');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports.filter = ({text, node}) => {
|
|
22
|
+
if (node.specifiers.length < 4)
|
|
23
|
+
return false;
|
|
24
|
+
|
|
25
|
+
return regExp.test(text);
|
|
26
|
+
};
|
|
27
|
+
|
package/lib/index.js
CHANGED
|
@@ -27,6 +27,7 @@ module.exports.rules = {
|
|
|
27
27
|
...getWrapRule('newline-function-call-arguments'),
|
|
28
28
|
...getWrapRule('function-declaration-paren-newline'),
|
|
29
29
|
...getWrapRule('add-newlines-between-types-in-union'),
|
|
30
|
+
...getWrapRule('add-newlines-between-specifiers'),
|
|
30
31
|
...getWrapRule('add-newline-before-function-call'),
|
|
31
32
|
...getWrapRule('add-newline-after-function-call'),
|
|
32
33
|
...getWrapRule('remove-newline-after-default-import'),
|
|
@@ -69,6 +70,7 @@ const recommended = {
|
|
|
69
70
|
'putout/newline-function-call-arguments': 'error',
|
|
70
71
|
'putout/function-declaration-paren-newline': 'error',
|
|
71
72
|
'putout/add-newlines-between-types-in-union': 'error',
|
|
73
|
+
'putout/add-newlines-between-specifiers': 'error',
|
|
72
74
|
'putout/add-newline-before-function-call': 'error',
|
|
73
75
|
'putout/add-newline-after-function-call': 'error',
|
|
74
76
|
'putout/remove-newline-after-default-import': 'error',
|