eslint-plugin-putout 27.2.1 → 28.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 +0 -2
- package/lib/index.mjs +0 -1
- package/lib/plugin.mjs +0 -1
- package/lib/ts.mjs +0 -5
- package/package.json +2 -2
- package/lib/keyword-spacing/index.js +0 -96
package/README.md
CHANGED
|
@@ -83,7 +83,6 @@ Then configure the rules you want to use under the rules section.
|
|
|
83
83
|
"putout/long-properties-destructuring": "error",
|
|
84
84
|
"putout/destructuring-as-function-argument": "error",
|
|
85
85
|
"putout/align-spaces": "error",
|
|
86
|
-
"putout/keyword-spacing": "error",
|
|
87
86
|
"putout/newline-function-call-arguments": "error",
|
|
88
87
|
"putout/function-declaration-paren-newline": "error",
|
|
89
88
|
"putout/remove-newline-after-default-import": "error",
|
|
@@ -139,7 +138,6 @@ Then configure the rules you want to use under the rules section.
|
|
|
139
138
|
- ✅ [For-of multiple properties destructuring](/packages/eslint-plugin-putout/lib/for-of-multiple-properties-destructuring#readme)
|
|
140
139
|
- ✅ [Long properties destructuring](/packages/eslint-plugin-putout/lib/long-properties-destructuring#readme)
|
|
141
140
|
- ✅ [Destructuring as function argument](/packages/eslint-plugin-putout/lib/destructuring-as-function-argument#readme)
|
|
142
|
-
- ✅ [Keyword spacing](/packages/eslint-plugin-putout/lib/keyword-spacing#readme)
|
|
143
141
|
- ✅ [Newline function call arguments](/packages/eslint-plugin-putout/lib/newline-function-call-arguments#readme)
|
|
144
142
|
- ✅ [Function declaration paren newline](/packages/eslint-plugin-putout/lib/function-declaration-paren-newline#readme)
|
|
145
143
|
- ✅ [Remove newline between declarations](/packages/eslint-plugin-putout/lib/remove-newline-between-declarations#readme)
|
package/lib/index.mjs
CHANGED
|
@@ -25,7 +25,6 @@ const putoutConfig = [{
|
|
|
25
25
|
'putout/long-properties-destructuring': 'error',
|
|
26
26
|
'putout/destructuring-as-function-argument': 'error',
|
|
27
27
|
'putout/align-spaces': 'error',
|
|
28
|
-
'putout/keyword-spacing': 'error',
|
|
29
28
|
'putout/newline-function-call-arguments': 'error',
|
|
30
29
|
'putout/function-declaration-paren-newline': 'error',
|
|
31
30
|
'putout/add-newlines-between-types-in-union': 'error',
|
package/lib/plugin.mjs
CHANGED
|
@@ -19,7 +19,6 @@ export const rules = {
|
|
|
19
19
|
...getWrapRule('long-properties-destructuring'),
|
|
20
20
|
...getWrapRule('destructuring-as-function-argument'),
|
|
21
21
|
...getWrapRule('align-spaces'),
|
|
22
|
-
...getWrapRule('keyword-spacing'),
|
|
23
22
|
...getWrapRule('newline-function-call-arguments'),
|
|
24
23
|
...getWrapRule('function-declaration-paren-newline'),
|
|
25
24
|
...getWrapRule('add-newlines-between-types-in-union'),
|
package/lib/ts.mjs
CHANGED
|
@@ -25,10 +25,6 @@ const handled = {
|
|
|
25
25
|
'@stylistic/brace-style': 'off', // putout/object-property-newline instead
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const broken = {
|
|
29
|
-
'@stylistic/indent': 'off',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
28
|
const slow = {
|
|
33
29
|
'@typescript-eslint/dot-notation': 'off',
|
|
34
30
|
'@typescript-eslint/require-await': 'off',
|
|
@@ -37,7 +33,6 @@ const slow = {
|
|
|
37
33
|
const extensionRules = {
|
|
38
34
|
...noFix,
|
|
39
35
|
...handled,
|
|
40
|
-
...broken,
|
|
41
36
|
...slow,
|
|
42
37
|
'no-undef': 'off',
|
|
43
38
|
'no-var': 'off',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "28.0.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "ESLint plugin for 🐊Putout",
|
|
6
6
|
"release": false,
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@typescript-eslint/parser": "^8.3.0",
|
|
50
50
|
"align-spaces": "^2.0.0",
|
|
51
51
|
"eslint-plugin-n": "^17.0.0",
|
|
52
|
-
"eslint-plugin-putout": "^
|
|
52
|
+
"eslint-plugin-putout": "^28.0.0",
|
|
53
53
|
"eslint-plugin-react": "^7.32.2",
|
|
54
54
|
"globals": "^16.0.0",
|
|
55
55
|
"parse-import-specifiers": "^1.0.1",
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
isTryStatement,
|
|
5
|
-
isSwitchStatement,
|
|
6
|
-
} = require('putout').types;
|
|
7
|
-
|
|
8
|
-
const keywords = {
|
|
9
|
-
IfStatement: 'if',
|
|
10
|
-
ForStatement: 'for',
|
|
11
|
-
ForOfStatement: 'for',
|
|
12
|
-
ForOfStatement_: 'for await',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const checkNodeSpace = ({text, node}) => {
|
|
16
|
-
const {type} = node;
|
|
17
|
-
const key = keywords[type];
|
|
18
|
-
const key_ = keywords[`${type}_`];
|
|
19
|
-
|
|
20
|
-
if (text.includes(`${key}(`))
|
|
21
|
-
return true;
|
|
22
|
-
|
|
23
|
-
return key_ && text.includes(`${key_}(`);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const fixNodeSpace = ({node, text}) => {
|
|
27
|
-
const {type} = node;
|
|
28
|
-
const key = keywords[type];
|
|
29
|
-
|
|
30
|
-
return text
|
|
31
|
-
.replace(`${key}(`, `${key} (`)
|
|
32
|
-
.replace(`for await(`, `for await (`);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
module.exports.report = (node) => {
|
|
36
|
-
if (isTryStatement(node))
|
|
37
|
-
return 'Use spaces around "catch"';
|
|
38
|
-
|
|
39
|
-
if (isSwitchStatement(node))
|
|
40
|
-
return 'Avoid space after "switch"';
|
|
41
|
-
|
|
42
|
-
return `Use space after "${keywords[node.type]}"`;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
module.exports.fix = ({node, text}) => {
|
|
46
|
-
if (isTryStatement(node))
|
|
47
|
-
return fixCatch(text);
|
|
48
|
-
|
|
49
|
-
if (isSwitchStatement(node))
|
|
50
|
-
return fixSwitch(text);
|
|
51
|
-
|
|
52
|
-
return fixNodeSpace({
|
|
53
|
-
node,
|
|
54
|
-
text,
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
module.exports.include = () => [
|
|
59
|
-
'TryStatement',
|
|
60
|
-
'SwitchStatement',
|
|
61
|
-
'IfStatement',
|
|
62
|
-
'ForStatement',
|
|
63
|
-
'ForOfStatement',
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
module.exports.filter = ({node, text}) => {
|
|
67
|
-
if (isTryStatement(node))
|
|
68
|
-
return checkCatch(text);
|
|
69
|
-
|
|
70
|
-
if (isSwitchStatement(node))
|
|
71
|
-
return checkSwitch(text);
|
|
72
|
-
|
|
73
|
-
return checkNodeSpace({
|
|
74
|
-
node,
|
|
75
|
-
text,
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
function checkCatch(text) {
|
|
80
|
-
const before = text.includes('}catch');
|
|
81
|
-
const after = text.includes('catch (');
|
|
82
|
-
const afterOptional = text.includes('catch{');
|
|
83
|
-
|
|
84
|
-
return before || after || afterOptional;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const checkSwitch = (text) => text.includes('switch (');
|
|
88
|
-
|
|
89
|
-
const fixCatch = (text) => text
|
|
90
|
-
.replaceAll('catch{', 'catch {')
|
|
91
|
-
.replaceAll('}catch', '} catch')
|
|
92
|
-
.replaceAll('catch (', 'catch(');
|
|
93
|
-
|
|
94
|
-
function fixSwitch(text) {
|
|
95
|
-
return text.replaceAll('switch (', 'switch(');
|
|
96
|
-
}
|