eslint-plugin-putout 13.7.0 → 13.9.2
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 +48 -47
- package/lib/function-declaration-paren-newline/README.md +18 -8
- package/lib/function-declaration-paren-newline/index.js +1 -0
- package/lib/index.js +1 -0
- package/lib/no-unresolved/index.js +1 -4
- package/lib/putout/index.js +2 -1
- package/lib/remove-newline-after-default-import/README.md +4 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,35 +60,35 @@ Then configure the rules you want to use under the rules section.
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
##
|
|
64
|
-
|
|
65
|
-
- [Add newlines between types in union](/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union)
|
|
66
|
-
- [Add newline before function call](/packages/eslint-plugin-putout/lib/add-newline-before-function-call)
|
|
67
|
-
- [Add newline after function call](/packages/eslint-plugin-putout/lib/add-newline-after-function-call)
|
|
68
|
-
- [Align spaces](/packages/eslint-plugin-putout/lib/align-spaces)
|
|
69
|
-
- [Array element newline](/packages/eslint-plugin-putout/lib/array-element-newline)
|
|
70
|
-
- [Evaluate](/packages/eslint-plugin-putout/lib/evaluate)
|
|
71
|
-
- [Putout](lib/putout)
|
|
72
|
-
- [Single property destructuring](/packages/eslint-plugin-putout/lib/single-property-destructuring)
|
|
73
|
-
- [Multiple properties destructuring](/packages/eslint-plugin-putout/lib/multiple-properties-destructuring)
|
|
74
|
-
- [For-of multiple properties destructuring](/packages/eslint-plugin-putout/lib/for-of-multiple-properties-destructuring)
|
|
75
|
-
- [Long properties destructuring](/packages/eslint-plugin-putout/lib/long-properties-destructuring)
|
|
76
|
-
- [Destructuring as function argument](/packages/eslint-plugin-putout/lib/destructuring-as-function-argument)
|
|
77
|
-
- [Keyword spacing](/packages/eslint-plugin-putout/lib/keyword-spacing)
|
|
78
|
-
- [Newline function call arguments](/packages/eslint-plugin-putout/lib/newline-function-call-arguments)
|
|
79
|
-
- [Function declaration paren newline](/packages/eslint-plugin-putout/lib/function-declaration-paren-newline)
|
|
80
|
-
- [Remove newline after default import](/packages/eslint-plugin-putout/lib/remove-newline-after-default-import)
|
|
81
|
-
- [Remove newline from empty object](/packages/eslint-plugin-putout/lib/remove-newline-from-empty-object)
|
|
82
|
-
- [Remove empty newline before first specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-before-first-specifier)
|
|
83
|
-
- [Remove empty newline after last specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-last-specifier)
|
|
84
|
-
- [Remove empty newline after import](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-import)
|
|
85
|
-
- [Remove empty specifiers](/packages/eslint-plugin-putout/lib/remove-empty-specifiers)
|
|
86
|
-
- [Objects braces inside array](/packages/eslint-plugin-putout/lib/objects-braces-inside-array)
|
|
87
|
-
- [Object init](/packages/eslint-plugin-putout/lib/object-init)
|
|
88
|
-
- [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved)
|
|
89
|
-
- [Tape: add newline before assertion]('/packages/eslint-plugin-putout/lib/tape-add-new-line-before-assertion)
|
|
90
|
-
- [Tape: add newline between tests]('/packages/eslint-plugin-putout/lib/tape-add-new-line-between-tests)
|
|
91
|
-
- [Tape: remove newline before t.end()]('/packages/eslint-plugin-putout/lib/tape-remove-newline-before-t-end)
|
|
63
|
+
## Rules
|
|
64
|
+
|
|
65
|
+
- [Add newlines between types in union](/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union#readme)
|
|
66
|
+
- [Add newline before function call](/packages/eslint-plugin-putout/lib/add-newline-before-function-call#readme)
|
|
67
|
+
- [Add newline after function call](/packages/eslint-plugin-putout/lib/add-newline-after-function-call#readme)
|
|
68
|
+
- [Align spaces](/packages/eslint-plugin-putout/lib/align-spaces#readme)
|
|
69
|
+
- [Array element newline](/packages/eslint-plugin-putout/lib/array-element-newline#readme)
|
|
70
|
+
- [Evaluate](/packages/eslint-plugin-putout/lib/evaluate#readme)
|
|
71
|
+
- [Putout](lib/putout#readme)
|
|
72
|
+
- [Single property destructuring](/packages/eslint-plugin-putout/lib/single-property-destructuring#readme)
|
|
73
|
+
- [Multiple properties destructuring](/packages/eslint-plugin-putout/lib/multiple-properties-destructuring#readme)
|
|
74
|
+
- [For-of multiple properties destructuring](/packages/eslint-plugin-putout/lib/for-of-multiple-properties-destructuring#readme)
|
|
75
|
+
- [Long properties destructuring](/packages/eslint-plugin-putout/lib/long-properties-destructuring#readme)
|
|
76
|
+
- [Destructuring as function argument](/packages/eslint-plugin-putout/lib/destructuring-as-function-argument#readme)
|
|
77
|
+
- [Keyword spacing](/packages/eslint-plugin-putout/lib/keyword-spacing#readme)
|
|
78
|
+
- [Newline function call arguments](/packages/eslint-plugin-putout/lib/newline-function-call-arguments#readme)
|
|
79
|
+
- [Function declaration paren newline](/packages/eslint-plugin-putout/lib/function-declaration-paren-newline#readme)
|
|
80
|
+
- [Remove newline after default import](/packages/eslint-plugin-putout/lib/remove-newline-after-default-import#readme)
|
|
81
|
+
- [Remove newline from empty object](/packages/eslint-plugin-putout/lib/remove-newline-from-empty-object#readme)
|
|
82
|
+
- [Remove empty newline before first specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-before-first-specifier#readme)
|
|
83
|
+
- [Remove empty newline after last specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-last-specifier#readme)
|
|
84
|
+
- [Remove empty newline after import](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-import#readme)
|
|
85
|
+
- [Remove empty specifiers](/packages/eslint-plugin-putout/lib/remove-empty-specifiers#readme)
|
|
86
|
+
- [Objects braces inside array](/packages/eslint-plugin-putout/lib/objects-braces-inside-array#readme)
|
|
87
|
+
- [Object init](/packages/eslint-plugin-putout/lib/object-init#readme)
|
|
88
|
+
- [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved#readme)
|
|
89
|
+
- [Tape: add newline before assertion]('/packages/eslint-plugin-putout/lib/tape-add-new-line-before-assertion#readme)
|
|
90
|
+
- [Tape: add newline between tests]('/packages/eslint-plugin-putout/lib/tape-add-new-line-between-tests#readme)
|
|
91
|
+
- [Tape: remove newline before t.end()]('/packages/eslint-plugin-putout/lib/tape-remove-newline-before-t-end#readme)
|
|
92
92
|
|
|
93
93
|
### Safe mode
|
|
94
94
|
|
|
@@ -107,27 +107,28 @@ When using 🐊`Putout` in IDE with `--fix` on save, or when you want to disable
|
|
|
107
107
|
|
|
108
108
|
Disabled `ESLint` rules:
|
|
109
109
|
|
|
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)
|
|
110
|
+
- [`no-useless-return`](https://eslint.org/docs/rules/no-useless-return#readme)
|
|
111
|
+
- [`putout/remove-newline-from-empty-object`](https://eslint.org/docs/rules/no-useless-return#readme)
|
|
112
112
|
|
|
113
113
|
Disabled 🐊`Putout` rules:
|
|
114
114
|
|
|
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-unreferenced-variables`](https://github.com/coderaiser/putout/tree/24.1.0/packages);
|
|
122
|
-
- [`remove-useless-return`](https://github.com/coderaiser/putout/tree/master/remove-useless-return);
|
|
123
|
-
- [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/remove-useless-arguments);
|
|
124
|
-
- [`remove-useless-
|
|
125
|
-
- [`remove-
|
|
126
|
-
- [`remove-
|
|
127
|
-
- [`remove-
|
|
128
|
-
- [`remove-
|
|
129
|
-
- [`remove-
|
|
130
|
-
- [`
|
|
115
|
+
- [`remove-empty`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-empty#readme);
|
|
116
|
+
- [`nodejs/remove-process-exit`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-nodejs#remove-process-exit#readme);
|
|
117
|
+
- [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-unused-variables#readme);
|
|
118
|
+
- [`typescript/remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.2/packages/plugin-typescript#remove-unused-types#readme);
|
|
119
|
+
- [`remove-unused-for-of-variables`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-unused-for-of-variables#readme);
|
|
120
|
+
- [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v24.0.0/packages#readme);
|
|
121
|
+
- [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/24.1.0/packages#readme);
|
|
122
|
+
- [`remove-useless-return`](https://github.com/coderaiser/putout/tree/master/remove-useless-return#readme);
|
|
123
|
+
- [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/remove-useless-arguments#readme);
|
|
124
|
+
- [`remove-useless-spread`](https://github.com/coderaiser/putout/tree/master/remove-useless-spread/#readme#readme);
|
|
125
|
+
- [`remove-useless-variables/rename`](https://github.com/coderaiser/putout/tree/master/remove-useless-arguments#rename#readme);
|
|
126
|
+
- [`remove-skip`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-skip#readme);
|
|
127
|
+
- [`remove-only`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-only#readme);
|
|
128
|
+
- [`remove-console`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-console#readme);
|
|
129
|
+
- [`remove-debugger`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-debugger#readme);
|
|
130
|
+
- [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/remove-unreachable-code#readme);
|
|
131
|
+
- [`convert-for-to-for-of`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/convert-for-to-for-of#readme);
|
|
131
132
|
|
|
132
133
|
### safe+align
|
|
133
134
|
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# function-declaration-paren-newline
|
|
2
2
|
|
|
3
|
-
Similar to `
|
|
3
|
+
Remove newlines between parens in function declaration. Similar to `ESLint` rule [function-paren-newline](https://eslint.org/docs/rules/function-declaration-paren-newline), but forbids new lines in function declarations and expressions arguments.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
This rule aims to add spaces around `catch`
|
|
8
|
-
|
|
9
|
-
Examples of **incorrect** code for this rule:
|
|
5
|
+
## ❌ Incorrect code example
|
|
10
6
|
|
|
11
7
|
```js
|
|
12
8
|
function f(
|
|
@@ -16,9 +12,17 @@ function f(
|
|
|
16
12
|
const fn = (
|
|
17
13
|
{a, b, c},
|
|
18
14
|
) => {};
|
|
15
|
+
|
|
16
|
+
regexpTree.traverse(ast, {
|
|
17
|
+
RegExp(
|
|
18
|
+
{node},
|
|
19
|
+
) {
|
|
20
|
+
const {body} = node;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
19
23
|
```
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
## ✅ Correct code example
|
|
22
26
|
|
|
23
27
|
```js
|
|
24
28
|
function f({a, b, c}) {}
|
|
@@ -31,4 +35,10 @@ const fnWithCall = ({a, b, c}) => {
|
|
|
31
35
|
b,
|
|
32
36
|
);
|
|
33
37
|
};
|
|
38
|
+
|
|
39
|
+
regexpTree.traverse(ast, {
|
|
40
|
+
RegExp({node}) {
|
|
41
|
+
const {body} = node;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
34
44
|
```
|
package/lib/index.js
CHANGED
|
@@ -116,6 +116,7 @@ const safe = {
|
|
|
116
116
|
'remove-useless-return': 'off',
|
|
117
117
|
'remove-useless-arguments': 'off',
|
|
118
118
|
'remove-useless-variables/rename': 'off',
|
|
119
|
+
'remove-useless-spread': 'off',
|
|
119
120
|
'remove-unreferenced-variables': 'off',
|
|
120
121
|
'tape/remove-skip': 'off',
|
|
121
122
|
'tape/remove-only': 'off',
|
|
@@ -16,10 +16,7 @@ const RELATIVE = '\\.\\.?\\/?';
|
|
|
16
16
|
const isRelativeStart = (a) => RegExp(`^${RELATIVE}`).test(a);
|
|
17
17
|
const isRelativeEnd = (a) => RegExp(`${RELATIVE}$`).test(a);
|
|
18
18
|
const getDir = (a) => a === '<input>' ? cwd : dirname(a);
|
|
19
|
-
const getValue = (
|
|
20
|
-
const {source} = node;
|
|
21
|
-
return source?.value;
|
|
22
|
-
};
|
|
19
|
+
const getValue = ({source}) => source?.value;
|
|
23
20
|
|
|
24
21
|
module.exports.category = 'errors';
|
|
25
22
|
module.exports.report = () => 'Always add an extension to relative imports';
|
package/lib/putout/index.js
CHANGED
|
@@ -96,6 +96,8 @@ const fix = ({ast, text, node, source, resultOptions}) => (fixer) => {
|
|
|
96
96
|
transform(ast, text, resultOptions);
|
|
97
97
|
|
|
98
98
|
const [, last] = lastToken.range;
|
|
99
|
+
|
|
100
|
+
removeParent(ast);
|
|
99
101
|
const code = print(ast);
|
|
100
102
|
|
|
101
103
|
return fixer.replaceTextRange([0, last], code);
|
|
@@ -103,7 +105,6 @@ const fix = ({ast, text, node, source, resultOptions}) => (fixer) => {
|
|
|
103
105
|
|
|
104
106
|
const createParser = (node) => {
|
|
105
107
|
const ast = copyAST(node);
|
|
106
|
-
removeParent(ast);
|
|
107
108
|
|
|
108
109
|
const parser = {
|
|
109
110
|
parse: returns(ast),
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# remove-newline-after-default-import
|
|
2
2
|
|
|
3
3
|
Fixes [`object-curly-newline`](https://eslint.org/docs/rules/object-curly-newline) + [`eslint-plugin-modules-newline`](https://github.com/gmsorrow/eslint-plugin-modules-newline).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This rule aims to remove newline after default import, before opening curly brace (`{`).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Examples of **incorrect** code for this rule:
|
|
7
|
+
## ❌ Incorrect code example
|
|
10
8
|
|
|
11
9
|
```js
|
|
12
10
|
import x,
|
|
@@ -16,7 +14,7 @@ import x,
|
|
|
16
14
|
} from 'y';
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
## ✅ Correct code example
|
|
20
18
|
|
|
21
19
|
```js
|
|
22
20
|
import x, {
|