eslint-plugin-putout 12.9.2 → 13.0.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
|
@@ -101,22 +101,28 @@ When using 🐊`Putout` in IDE with `--fix` on save, or when you want to disable
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
### safe+align
|
|
105
|
+
|
|
106
|
+
When you want to enable ability to align spaces on empty lines, use `safe+align`.
|
|
107
|
+
|
|
104
108
|
Disabled `ESLint` rules:
|
|
105
109
|
|
|
106
|
-
- [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)
|
|
107
112
|
|
|
108
113
|
Disabled 🐊`Putout` rules:
|
|
109
114
|
|
|
110
|
-
- [remove-empty](https://github.com/coderaiser/putout/tree/
|
|
111
|
-
- [remove-
|
|
112
|
-
- [remove-unused-
|
|
113
|
-
- [remove-unused-
|
|
114
|
-
- [remove-unused-
|
|
115
|
-
- [remove-
|
|
116
|
-
- [remove-useless-
|
|
117
|
-
- [remove-
|
|
118
|
-
- [remove-
|
|
119
|
-
- [remove-
|
|
120
|
-
- [remove-
|
|
121
|
-
- [remove-
|
|
122
|
-
- [
|
|
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
|
+
- [`remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/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,9 +99,11 @@ 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',
|
|
106
|
+
'nodejs/remove-process-exit': 'off',
|
|
105
107
|
'remove-unused-types': 'off',
|
|
106
108
|
'remove-unused-variables': 'off',
|
|
107
109
|
'remove-unused-expressions': 'off',
|
|
@@ -122,5 +124,12 @@ const safe = {
|
|
|
122
124
|
module.exports.configs = {
|
|
123
125
|
recommended,
|
|
124
126
|
safe,
|
|
127
|
+
'safe+align': {
|
|
128
|
+
...safe,
|
|
129
|
+
rules: {
|
|
130
|
+
...safe.rules,
|
|
131
|
+
'putout/align-spaces': 'error',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
125
134
|
};
|
|
126
135
|
|
|
@@ -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.0",
|
|
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": {
|