eslint-plugin-putout 12.10.0 → 13.0.1
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
|
@@ -107,20 +107,22 @@ When you want to enable ability to align spaces on empty lines, use `safe+align`
|
|
|
107
107
|
|
|
108
108
|
Disabled `ESLint` rules:
|
|
109
109
|
|
|
110
|
-
- [no-useless-return](https://eslint.org/docs/rules/no-useless-return)
|
|
110
|
+
- [`no-useless-return`](https://eslint.org/docs/rules/no-useless-return)
|
|
111
|
+
- [`putout/remove-newline-from-empty-object`](https://eslint.org/docs/rules/no-useless-return)
|
|
111
112
|
|
|
112
113
|
Disabled 🐊`Putout` rules:
|
|
113
114
|
|
|
114
|
-
- [remove-empty](https://github.com/coderaiser/putout/tree/
|
|
115
|
-
- [remove-
|
|
116
|
-
- [remove-unused-
|
|
117
|
-
- [remove-unused-
|
|
118
|
-
- [remove-unused-
|
|
119
|
-
- [remove-
|
|
120
|
-
- [remove-useless-
|
|
121
|
-
- [remove-
|
|
122
|
-
- [remove-
|
|
123
|
-
- [remove-
|
|
124
|
-
- [remove-
|
|
125
|
-
- [remove-
|
|
126
|
-
- [
|
|
115
|
+
- [`remove-empty`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-empty);
|
|
116
|
+
- [`nodejs/remove-process-exit`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-nodejs#remove-process-exit);
|
|
117
|
+
- [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-unused-variables);
|
|
118
|
+
- [`typescript/remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.2/packages/plugin-typescript#remove-unused-types);
|
|
119
|
+
- [`remove-unused-for-of-variables`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-unused-for-of-variables);
|
|
120
|
+
- [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v24.0.0/packages);
|
|
121
|
+
- [`remove-useless-return`](https://github.com/coderaiser/putout/tree/master/remove-useless-return);
|
|
122
|
+
- [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/remove-useless-arguments);
|
|
123
|
+
- [`remove-skip`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-skip);
|
|
124
|
+
- [`remove-only`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-only);
|
|
125
|
+
- [`remove-console`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-console);
|
|
126
|
+
- [`remove-debugger`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-debugger);
|
|
127
|
+
- [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-unreachable-code);
|
|
128
|
+
- [`convert-for-to-for-of`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/convert-for-to-for-of);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule Details
|
|
4
4
|
|
|
5
|
-
This rule aims to add newline before function call
|
|
5
|
+
This rule aims to add newline before `function call` and `assignment`.
|
|
6
6
|
|
|
7
7
|
Examples of **incorrect** code for this rule:
|
|
8
8
|
|
|
@@ -12,6 +12,10 @@ export function parse() {
|
|
|
12
12
|
const b = 2;
|
|
13
13
|
fn();
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
export function calc() {
|
|
17
|
+
const b = 2;
|
|
18
|
+
}
|
|
15
19
|
```
|
|
16
20
|
|
|
17
21
|
Examples of **correct** code for this rule:
|
|
@@ -23,4 +27,8 @@ export function parse() {
|
|
|
23
27
|
|
|
24
28
|
fn();
|
|
25
29
|
}
|
|
30
|
+
|
|
31
|
+
export function calc() {
|
|
32
|
+
const b = 2;
|
|
33
|
+
}
|
|
26
34
|
```
|
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
const regExp = /^\n( +)?\n +$/;
|
|
12
12
|
|
|
13
13
|
module.exports.category = 'typescript';
|
|
14
|
-
module.exports.report = () => 'Add newline before
|
|
14
|
+
module.exports.report = () => 'Add newline before expression';
|
|
15
15
|
|
|
16
16
|
module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) => {
|
|
17
17
|
if (!isExpressionStatement(node.parent))
|
|
@@ -69,5 +69,5 @@ module.exports.fix = ({text}) => {
|
|
|
69
69
|
|
|
70
70
|
module.exports.include = () => [
|
|
71
71
|
'CallExpression',
|
|
72
|
+
'AssignmentExpression',
|
|
72
73
|
];
|
|
73
|
-
|
package/lib/index.js
CHANGED
|
@@ -99,10 +99,12 @@ const safe = {
|
|
|
99
99
|
...recommended.rules,
|
|
100
100
|
'no-useless-return': 'off',
|
|
101
101
|
'putout/align-spaces': 'off',
|
|
102
|
+
'putout/remove-newline-from-empty-object': 'off',
|
|
102
103
|
'putout/putout': ['error', {
|
|
103
104
|
rules: {
|
|
104
105
|
'remove-empty': 'off',
|
|
105
|
-
'remove-
|
|
106
|
+
'nodejs/remove-process-exit': 'off',
|
|
107
|
+
'typescript/remove-unused-types': 'off',
|
|
106
108
|
'remove-unused-variables': 'off',
|
|
107
109
|
'remove-unused-expressions': 'off',
|
|
108
110
|
'remove-unused-for-of-variables': 'off',
|
|
@@ -8,7 +8,12 @@ module.exports.report = () => 'Remove newline from empty object';
|
|
|
8
8
|
|
|
9
9
|
const regExp = /\n/;
|
|
10
10
|
|
|
11
|
-
module.exports.filter = ({text, node}) => {
|
|
11
|
+
module.exports.filter = ({text, node, getCommentsInside}) => {
|
|
12
|
+
const comments = getCommentsInside(node);
|
|
13
|
+
|
|
14
|
+
if (comments.length)
|
|
15
|
+
return false;
|
|
16
|
+
|
|
12
17
|
if (isArrayExpression(node.parent))
|
|
13
18
|
return false;
|
|
14
19
|
|
package/lib/wrap.js
CHANGED
|
@@ -8,6 +8,7 @@ const prepare = (plugin, context, options) => (node) => {
|
|
|
8
8
|
const getText = source.getText.bind(source);
|
|
9
9
|
const getCommentsBefore = source.getCommentsBefore.bind(source);
|
|
10
10
|
const getCommentsAfter = source.getCommentsAfter.bind(source);
|
|
11
|
+
const getCommentsInside = source.getCommentsInside.bind(source);
|
|
11
12
|
|
|
12
13
|
const getSpacesBeforeNode = createGetSpacesBeforeNode({
|
|
13
14
|
getText,
|
|
@@ -26,6 +27,7 @@ const prepare = (plugin, context, options) => (node) => {
|
|
|
26
27
|
getText,
|
|
27
28
|
getCommentsBefore,
|
|
28
29
|
getCommentsAfter,
|
|
30
|
+
getCommentsInside,
|
|
29
31
|
getSpacesBeforeNode,
|
|
30
32
|
getSpacesAfterNode,
|
|
31
33
|
filename,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "eslint plugin for putout",
|
|
6
6
|
"release": false,
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"eslint": ">=8.0.0",
|
|
67
|
-
"putout": ">=
|
|
67
|
+
"putout": ">=24"
|
|
68
68
|
},
|
|
69
69
|
"license": "MIT",
|
|
70
70
|
"publishConfig": {
|