eslint-plugin-putout 27.2.0 → 28.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 +0 -2
- package/lib/index.mjs +0 -1
- package/lib/plugin.mjs +0 -1
- package/lib/ts.mjs +3 -2
- package/package.json +1 -1
- 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
|
@@ -162,13 +162,14 @@ function convertPaddingLines([state, ...lines]) {
|
|
|
162
162
|
|
|
163
163
|
function getOperatorLinebreak(options) {
|
|
164
164
|
const [error, after, {overrides}] = options;
|
|
165
|
+
const newOverrides = assign({}, overrides);
|
|
165
166
|
|
|
166
|
-
delete
|
|
167
|
+
delete newOverrides['='];
|
|
167
168
|
|
|
168
169
|
return [
|
|
169
170
|
error,
|
|
170
171
|
after, {
|
|
171
|
-
overrides,
|
|
172
|
+
overrides: newOverrides,
|
|
172
173
|
},
|
|
173
174
|
];
|
|
174
175
|
}
|
package/package.json
CHANGED
|
@@ -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
|
-
}
|