eslint-plugin-putout 10.10.0 → 11.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 +4 -0
- package/lib/index.js +7 -2
- package/lib/remove-empty-newline-after-last-specifier/README.md +24 -0
- package/lib/remove-empty-newline-after-last-specifier/index.js +20 -0
- package/lib/tape-add-newline-between-tests/README.md +42 -0
- package/lib/tape-add-newline-between-tests/index.js +27 -0
- package/lib/wrap.js +2 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ Then configure the rules you want to use under the rules section.
|
|
|
49
49
|
"putout/newline-function-call-arguments": "error",
|
|
50
50
|
"putout/function-declaration-paren-newline": "error",
|
|
51
51
|
"putout/remove-newline-after-default-import": "error",
|
|
52
|
+
"putout/remove-empty-newline-after-last-specifier": "error",
|
|
52
53
|
"putout/objects-braces-inside-array": "error",
|
|
53
54
|
"putout/object-init": "error"
|
|
54
55
|
}
|
|
@@ -68,11 +69,13 @@ Then configure the rules you want to use under the rules section.
|
|
|
68
69
|
- [Newline function call arguments](/packages/eslint-plugin-putout/lib/newline-function-call-arguments)
|
|
69
70
|
- [Function declaration paren newline](/packages/eslint-plugin-putout/lib/function-declaration-paren-newline)
|
|
70
71
|
- [Remove newline after default import](/packages/eslint-plugin-putout/lib/remove-newline-after-default-import)
|
|
72
|
+
- [Remove empty newline after last specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-last-specifier)
|
|
71
73
|
- [Objects braces inside array](/packages/eslint-plugin-putout/lib/objects-braces-inside-array)
|
|
72
74
|
- [Object init](/packages/eslint-plugin-putout/lib/object-init)
|
|
73
75
|
- [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved)
|
|
74
76
|
- [Evaluate](/packages/eslint-plugin-putout/lib/evaluate)
|
|
75
77
|
- [Tape: add new line before assertion]('/packages/eslint-plugin-putout/lib/tape-add-new-line-before-assertion)
|
|
78
|
+
- [Tape: add new line between tests]('/packages/eslint-plugin-putout/lib/tape-add-new-line-between-tests)
|
|
76
79
|
|
|
77
80
|
### Safe mode
|
|
78
81
|
|
|
@@ -96,6 +99,7 @@ List of disabled `putout` rules:
|
|
|
96
99
|
- [remove-unused-types](https://github.com/coderaiser/putout/tree/v20.0.0/packages/remove-unused-types);
|
|
97
100
|
- [remove-unused-for-of-variables](https://github.com/coderaiser/putout/tree/v20.0.0/packages/remove-unused-for-of-variables);
|
|
98
101
|
- [remove-unused-expressions](https://github.com/coderaiser/putout/tree/v20.0.0/packages);
|
|
102
|
+
- [remove-useless-return](https://github.com/coderaiser/putout/tree/master/remove-useless-return);
|
|
99
103
|
- [remove-skip](https://github.com/coderaiser/putout/tree/v20.0.0/packages/remove-skip);
|
|
100
104
|
- [remove-only](https://github.com/coderaiser/putout/tree/v20.0.0/packages/remove-only);
|
|
101
105
|
- [remove-console](https://github.com/coderaiser/putout/tree/v20.0.0/packages/remove-console);
|
package/lib/index.js
CHANGED
|
@@ -26,11 +26,13 @@ module.exports.rules = {
|
|
|
26
26
|
...getWrapRule('newline-function-call-arguments'),
|
|
27
27
|
...getWrapRule('function-declaration-paren-newline'),
|
|
28
28
|
...getWrapRule('remove-newline-after-default-import'),
|
|
29
|
+
...getWrapRule('remove-empty-newline-after-last-specifier'),
|
|
29
30
|
...getWrapRule('objects-braces-inside-array'),
|
|
30
31
|
...getWrapRule('object-init'),
|
|
31
32
|
...getWrapRule('no-unresolved'),
|
|
32
33
|
...getWrapRule('evaluate'),
|
|
33
34
|
...getWrapRule('tape-add-newline-before-assertion'),
|
|
35
|
+
...getWrapRule('tape-add-newline-between-tests'),
|
|
34
36
|
...getRule('putout'),
|
|
35
37
|
};
|
|
36
38
|
|
|
@@ -54,11 +56,13 @@ const recommended = {
|
|
|
54
56
|
'putout/newline-function-call-arguments': 'error',
|
|
55
57
|
'putout/function-declaration-paren-newline': 'error',
|
|
56
58
|
'putout/remove-newline-after-default-import': 'error',
|
|
59
|
+
'putout/remove-empty-newline-after-last-specifier': 'error',
|
|
57
60
|
'putout/objects-braces-inside-array': 'error',
|
|
58
61
|
'putout/object-init': 'error',
|
|
59
62
|
'putout/no-unresolved': 'error',
|
|
60
63
|
'putout/evaluate': 'error',
|
|
61
64
|
'putout/tape-add-newline-before-assertion': 'error',
|
|
65
|
+
'putout/tape-add-newline-between-tests': 'error',
|
|
62
66
|
'putout/putout': 'error',
|
|
63
67
|
|
|
64
68
|
'node/no-unsupported-features/es-syntax': 'off',
|
|
@@ -87,8 +91,9 @@ const safe = {
|
|
|
87
91
|
'remove-unused-variables': 'off',
|
|
88
92
|
'remove-unused-expressions': 'off',
|
|
89
93
|
'remove-unused-for-of-variables': 'off',
|
|
90
|
-
'remove-
|
|
91
|
-
'remove-
|
|
94
|
+
'remove-useless-return': 'off',
|
|
95
|
+
'tape/remove-skip': 'off',
|
|
96
|
+
'tape/remove-only': 'off',
|
|
92
97
|
'remove-console': 'off',
|
|
93
98
|
'remove-debugger': 'off',
|
|
94
99
|
'convert-for-to-for-of': 'off',
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Remove empty new line after last specifier(remove-empty-newline-after-last-specifier)
|
|
2
|
+
|
|
3
|
+
## Rule Details
|
|
4
|
+
|
|
5
|
+
This rule aims to remove empty newline after last specifier.
|
|
6
|
+
|
|
7
|
+
Examples of **incorrect** code for this rule:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import {
|
|
11
|
+
a,
|
|
12
|
+
b,
|
|
13
|
+
|
|
14
|
+
} from 'y';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Examples of **correct** code for this rule:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import {
|
|
21
|
+
a,
|
|
22
|
+
b,
|
|
23
|
+
} from 'y';
|
|
24
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.category = 'import';
|
|
4
|
+
module.exports.report = () => 'Remove newline after last specifier';
|
|
5
|
+
|
|
6
|
+
const regExp = /\n\s+}/;
|
|
7
|
+
|
|
8
|
+
module.exports.filter = ({text}) => {
|
|
9
|
+
return regExp.test(text);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports.fix = ({text}) => {
|
|
13
|
+
return text
|
|
14
|
+
.replace(regExp, '\n}');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports.include = () => [
|
|
18
|
+
'ImportDeclaration',
|
|
19
|
+
];
|
|
20
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Add new line between tests (add-newline-between-tests)
|
|
2
|
+
|
|
3
|
+
Add new line between tests, for [supertape](https://github.com/coderaiser/supertape).
|
|
4
|
+
|
|
5
|
+
## Rule Details
|
|
6
|
+
|
|
7
|
+
This rule aims to add new line between tests.
|
|
8
|
+
|
|
9
|
+
Examples of **incorrect** code for this rule:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
test('lint: do some check', (t) => {
|
|
13
|
+
const result = 1 + 2;
|
|
14
|
+
|
|
15
|
+
t.equal(result, 3);
|
|
16
|
+
t.end();
|
|
17
|
+
});
|
|
18
|
+
test('lint: do some check', (t) => {
|
|
19
|
+
const result = 1 + 2;
|
|
20
|
+
|
|
21
|
+
t.equal(result, 3);
|
|
22
|
+
t.end();
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Examples of **correct** code for this rule:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
test('lint: do some check', (t) => {
|
|
30
|
+
const result = 1 + 2;
|
|
31
|
+
|
|
32
|
+
t.equal(result, 3);
|
|
33
|
+
t.end();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('lint: do some check', (t) => {
|
|
37
|
+
const result = 1 + 2;
|
|
38
|
+
|
|
39
|
+
t.equal(result, 3);
|
|
40
|
+
t.end();
|
|
41
|
+
});
|
|
42
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.category = 'tape';
|
|
4
|
+
module.exports.report = () => 'Add new line between tests';
|
|
5
|
+
|
|
6
|
+
module.exports.filter = ({text, node, getText, getCommentsBefore}) => {
|
|
7
|
+
if (!/^test(\.only|\.skip)?\(/.test(text))
|
|
8
|
+
return false;
|
|
9
|
+
|
|
10
|
+
const comments = getCommentsBefore(node);
|
|
11
|
+
|
|
12
|
+
if (comments.length)
|
|
13
|
+
return false;
|
|
14
|
+
|
|
15
|
+
const [a] = getText(node, 2);
|
|
16
|
+
|
|
17
|
+
return a === ';';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports.fix = ({text}) => {
|
|
21
|
+
return `\n${text}`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports.include = () => [
|
|
25
|
+
'CallExpression ',
|
|
26
|
+
];
|
|
27
|
+
|
package/lib/wrap.js
CHANGED
|
@@ -6,6 +6,7 @@ const prepare = (plugin, context, options) => (node) => {
|
|
|
6
6
|
const source = context.getSourceCode();
|
|
7
7
|
const filename = context.getFilename();
|
|
8
8
|
const getText = source.getText.bind(source);
|
|
9
|
+
const getCommentsBefore = source.getCommentsBefore.bind(source);
|
|
9
10
|
|
|
10
11
|
const text = getText(node);
|
|
11
12
|
|
|
@@ -14,6 +15,7 @@ const prepare = (plugin, context, options) => (node) => {
|
|
|
14
15
|
node,
|
|
15
16
|
options,
|
|
16
17
|
getText,
|
|
18
|
+
getCommentsBefore,
|
|
17
19
|
filename,
|
|
18
20
|
});
|
|
19
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"description": "eslint plugin for putout",
|
|
5
5
|
"release": false,
|
|
6
6
|
"tag": false,
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"node": ">=14"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"eslint": ">=8.0.0
|
|
62
|
-
"putout": ">=
|
|
61
|
+
"eslint": ">=8.0.0",
|
|
62
|
+
"putout": ">=21"
|
|
63
63
|
},
|
|
64
64
|
"license": "MIT",
|
|
65
65
|
"publishConfig": {
|