eslint-plugin-putout 17.7.0 → 18.1.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 +5 -1
- package/lib/add-newline-after-function-call/index.js +1 -1
- package/lib/add-newline-before-function-call/index.js +1 -4
- package/lib/add-newline-before-return/index.js +2 -5
- package/lib/add-newlines-between-specifiers/index.js +0 -1
- package/lib/add-newlines-between-types-in-union/README.md +2 -2
- package/lib/add-newlines-between-types-in-union/index.js +0 -1
- package/lib/align-spaces/index.js +1 -4
- package/lib/array-element-newline/index.js +9 -11
- package/lib/common.js +0 -1
- package/lib/config/index.js +0 -1
- package/lib/destructuring-as-function-argument/index.js +0 -1
- package/lib/evaluate/index.js +5 -6
- package/lib/for-of-multiple-properties-destructuring/index.js +2 -8
- package/lib/function-declaration-paren-newline/index.js +1 -1
- package/lib/html.js +0 -1
- package/lib/index.js +12 -1
- package/lib/json.js +24 -7
- package/lib/jsx.js +0 -1
- package/lib/keyword-spacing/index.js +10 -9
- package/lib/long-properties-destructuring/index.js +4 -6
- package/lib/markdown.js +10 -6
- package/lib/multiple-properties-destructuring/index.js +3 -1
- package/lib/newline-function-call-arguments/index.js +1 -5
- package/lib/no-unresolved/index.js +0 -1
- package/lib/nonblock-statement-body-newline/index.js +1 -4
- package/lib/object-property-newline/index.js +1 -5
- package/lib/objects-braces-inside-array/index.js +0 -1
- package/lib/remove-empty-newline-after-import/index.js +2 -4
- package/lib/remove-empty-newline-after-last-element/index.js +1 -3
- package/lib/remove-empty-newline-after-last-specifier/index.js +1 -3
- package/lib/remove-empty-newline-before-first-specifier/index.js +1 -3
- package/lib/remove-empty-newline-between-declarations/index.js +1 -0
- package/lib/remove-empty-specifiers/index.js +0 -1
- package/lib/remove-newline-after-default-import/index.js +1 -3
- package/lib/remove-newline-from-empty-object/index.js +0 -1
- package/lib/single-property-destructuring/index.js +3 -12
- package/lib/tape-add-newline-between-tests/index.js +0 -1
- package/lib/tape-remove-newline-before-t-end/index.js +5 -6
- package/lib/ts.js +19 -32
- package/lib/yaml.js +0 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -197,7 +197,11 @@ The time is came for a [FlatConfig](https://eslint.org/blog/2022/08/new-config-s
|
|
|
197
197
|
|
|
198
198
|
```js
|
|
199
199
|
const {recommended} = require('eslint-plugin-putout/config');
|
|
200
|
-
|
|
200
|
+
|
|
201
|
+
module.exports = [
|
|
202
|
+
...recommended,
|
|
203
|
+
{},
|
|
204
|
+
];
|
|
201
205
|
```
|
|
202
206
|
|
|
203
207
|
`safe` and `safeAlign` supported as well.
|
|
@@ -69,6 +69,7 @@ module.exports.filter = ({node, getCommentsAfter, getSpacesAfterNode}) => {
|
|
|
69
69
|
return true;
|
|
70
70
|
|
|
71
71
|
const spacesAfterPrev = getSpacesAfterNode(prev);
|
|
72
|
+
|
|
72
73
|
return !regExp.test(spacesAfterPrev);
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -82,4 +83,3 @@ module.exports.fix = ({text}) => {
|
|
|
82
83
|
module.exports.include = () => [
|
|
83
84
|
'CallExpression',
|
|
84
85
|
];
|
|
85
|
-
|
|
@@ -54,10 +54,7 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
|
|
|
54
54
|
|
|
55
55
|
const spaces = getSpacesBeforeNode(prevA);
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
return false;
|
|
59
|
-
|
|
60
|
-
return true;
|
|
57
|
+
return !regExp.test(spaces);
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
return false;
|
|
@@ -27,7 +27,7 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
|
|
|
27
27
|
let i = n - 1;
|
|
28
28
|
let count = 0;
|
|
29
29
|
|
|
30
|
-
while(--i) {
|
|
30
|
+
while (--i) {
|
|
31
31
|
const prevA = body[i];
|
|
32
32
|
const spaces = getSpacesBeforeNode(prevA);
|
|
33
33
|
|
|
@@ -37,10 +37,7 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
|
|
|
37
37
|
++count;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
return false;
|
|
42
|
-
|
|
43
|
-
return true;
|
|
40
|
+
return !(count < 1);
|
|
44
41
|
};
|
|
45
42
|
|
|
46
43
|
module.exports.fix = ({text}) => {
|
|
@@ -5,13 +5,13 @@ This rule aims to add newlines between types in union. Part of [`eslint-plugin-p
|
|
|
5
5
|
## ❌ Example of incorrect code
|
|
6
6
|
|
|
7
7
|
```js
|
|
8
|
-
|
|
8
|
+
type a = string | number | object | boolean;
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## ✅ Example of correct code
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
|
|
14
|
+
type a = string
|
|
15
15
|
| number
|
|
16
16
|
| object
|
|
17
17
|
| boolean;
|
|
@@ -5,9 +5,7 @@ const alignedMap = new Map();
|
|
|
5
5
|
|
|
6
6
|
module.exports.report = () => 'Spaces should be aligned on empty lines';
|
|
7
7
|
|
|
8
|
-
module.exports.include = () => [
|
|
9
|
-
'Program',
|
|
10
|
-
];
|
|
8
|
+
module.exports.include = () => ['Program'];
|
|
11
9
|
|
|
12
10
|
module.exports.fix = ({text}) => {
|
|
13
11
|
return alignedMap.get(text);
|
|
@@ -23,4 +21,3 @@ module.exports.filter = ({text}) => {
|
|
|
23
21
|
|
|
24
22
|
return true;
|
|
25
23
|
};
|
|
26
|
-
|
|
@@ -15,6 +15,7 @@ module.exports.category = 'array';
|
|
|
15
15
|
module.exports.report = () => 'Add newlines between array elements';
|
|
16
16
|
|
|
17
17
|
const regexp = /['"\da-zA-Z]+, ['"\da-zA-Z]/;
|
|
18
|
+
|
|
18
19
|
const isSupportedNode = (a) => {
|
|
19
20
|
if (!a)
|
|
20
21
|
return false;
|
|
@@ -22,10 +23,7 @@ const isSupportedNode = (a) => {
|
|
|
22
23
|
if (a.type === 'Literal')
|
|
23
24
|
return true;
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
return true;
|
|
27
|
-
|
|
28
|
-
return false;
|
|
26
|
+
return a.type === 'Identifier';
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
module.exports.filter = ({text, node}) => {
|
|
@@ -61,16 +59,17 @@ module.exports.filter = ({text, node}) => {
|
|
|
61
59
|
if (node.elements.length < 5 && isShortValues(node.elements))
|
|
62
60
|
return false;
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
return true;
|
|
66
|
-
|
|
67
|
-
return false;
|
|
62
|
+
return regexp.test(text);
|
|
68
63
|
};
|
|
69
64
|
module.exports.fix = ({text}) => {
|
|
70
|
-
return text
|
|
65
|
+
return text
|
|
66
|
+
.replace(/\[/g, '[\n')
|
|
67
|
+
.replace(/\]/g, '\n]')
|
|
71
68
|
.replace(/,/g, ',\n');
|
|
72
69
|
};
|
|
73
|
-
module.exports.include = () => [
|
|
70
|
+
module.exports.include = () => [
|
|
71
|
+
'ArrayExpression',
|
|
72
|
+
];
|
|
74
73
|
|
|
75
74
|
function isShortValues(elements) {
|
|
76
75
|
for (const {type, value} of elements) {
|
|
@@ -126,4 +125,3 @@ function differentTypes({elements}) {
|
|
|
126
125
|
|
|
127
126
|
return false;
|
|
128
127
|
}
|
|
129
|
-
|
package/lib/common.js
CHANGED
package/lib/config/index.js
CHANGED
package/lib/evaluate/index.js
CHANGED
|
@@ -5,15 +5,13 @@ const putout = require('putout');
|
|
|
5
5
|
|
|
6
6
|
module.exports.category = 'evaluate';
|
|
7
7
|
module.exports.report = () => 'Evaluate expression';
|
|
8
|
-
module.exports.include = () => [
|
|
8
|
+
module.exports.include = () => [
|
|
9
|
+
'ImportDeclaration',
|
|
10
|
+
];
|
|
9
11
|
|
|
10
12
|
module.exports.filter = ({node}) => {
|
|
11
13
|
const {value} = node.source;
|
|
12
|
-
|
|
13
|
-
if (!value.startsWith('__putout_evaluate:'))
|
|
14
|
-
return false;
|
|
15
|
-
|
|
16
|
-
return true;
|
|
14
|
+
return value.startsWith('__putout_evaluate:');
|
|
17
15
|
};
|
|
18
16
|
|
|
19
17
|
module.exports.fix = ({text, node, filename}) => {
|
|
@@ -42,5 +40,6 @@ function evaluate({value, filename}) {
|
|
|
42
40
|
});
|
|
43
41
|
|
|
44
42
|
const fn = Function('__filename', '__dirname', 'require', code);
|
|
43
|
+
|
|
45
44
|
return fn(filename, dirname(filename), require);
|
|
46
45
|
}
|
|
@@ -6,19 +6,14 @@ module.exports.report = () => 'Keep all properties in one line when using destru
|
|
|
6
6
|
module.exports.include = ({options}) => {
|
|
7
7
|
const {maxProperties = 8} = options[0] || {};
|
|
8
8
|
|
|
9
|
-
return [
|
|
10
|
-
`VariableDeclarator[id.type="ObjectPattern"][id.properties.length<${maxProperties}]`,
|
|
11
|
-
];
|
|
9
|
+
return [`VariableDeclarator[id.type="ObjectPattern"][id.properties.length<${maxProperties}]`];
|
|
12
10
|
};
|
|
13
11
|
|
|
14
12
|
module.exports.filter = ({node, text}) => {
|
|
15
13
|
if (node.parent.parent.type !== 'ForOfStatement')
|
|
16
14
|
return false;
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
return false;
|
|
20
|
-
|
|
21
|
-
return true;
|
|
16
|
+
return text.includes('\n');
|
|
22
17
|
};
|
|
23
18
|
|
|
24
19
|
module.exports.fix = ({text}) => {
|
|
@@ -28,4 +23,3 @@ module.exports.fix = ({text}) => {
|
|
|
28
23
|
.replace(/{\s*/g, '{')
|
|
29
24
|
.replace(/\s*}/g, '}');
|
|
30
25
|
};
|
|
31
|
-
|
|
@@ -6,6 +6,7 @@ module.exports.report = () => {
|
|
|
6
6
|
|
|
7
7
|
module.exports.fix = ({text, node, getText}) => {
|
|
8
8
|
const {body} = node.body;
|
|
9
|
+
|
|
9
10
|
node.body.body = [];
|
|
10
11
|
|
|
11
12
|
const paramsText = getText(node);
|
|
@@ -41,4 +42,3 @@ function checkFunction(text) {
|
|
|
41
42
|
|
|
42
43
|
return before || after;
|
|
43
44
|
}
|
|
44
|
-
|
package/lib/html.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -7,9 +7,11 @@ const yaml = require('./yaml');
|
|
|
7
7
|
const html = require('./html');
|
|
8
8
|
const ts = require('./ts');
|
|
9
9
|
const jsx = require('./jsx');
|
|
10
|
+
|
|
10
11
|
const getRule = (a) => ({
|
|
11
12
|
[a]: require(`./${a}`),
|
|
12
13
|
});
|
|
14
|
+
|
|
13
15
|
const getWrapRule = (a) => ({
|
|
14
16
|
[a]: createPlugin(require(`./${a}`)),
|
|
15
17
|
});
|
|
@@ -51,6 +53,7 @@ module.exports.rules = {
|
|
|
51
53
|
};
|
|
52
54
|
const config = require('@putout/eslint-config');
|
|
53
55
|
const {rules} = config;
|
|
56
|
+
|
|
54
57
|
const recommended = {
|
|
55
58
|
...config,
|
|
56
59
|
rules: {
|
|
@@ -95,9 +98,17 @@ const recommended = {
|
|
|
95
98
|
'n/no-missing-require': 'off',
|
|
96
99
|
'n/no-process-exit': 'off',
|
|
97
100
|
},
|
|
98
|
-
overrides: [
|
|
101
|
+
overrides: [
|
|
102
|
+
...markdown,
|
|
103
|
+
...json,
|
|
104
|
+
...yaml,
|
|
105
|
+
...html,
|
|
106
|
+
...ts,
|
|
107
|
+
...jsx,
|
|
108
|
+
],
|
|
99
109
|
plugins: ['n'],
|
|
100
110
|
};
|
|
111
|
+
|
|
101
112
|
const safe = {
|
|
102
113
|
...recommended,
|
|
103
114
|
rules: {
|
package/lib/json.js
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = [{
|
|
4
|
-
files: [
|
|
4
|
+
files: [
|
|
5
|
+
'*.json',
|
|
6
|
+
'*{json}',
|
|
7
|
+
],
|
|
5
8
|
rules: {
|
|
6
|
-
'quotes': [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
'quotes': [
|
|
10
|
+
'error',
|
|
11
|
+
'double',
|
|
12
|
+
],
|
|
13
|
+
'quote-props': [
|
|
14
|
+
'error',
|
|
15
|
+
'always',
|
|
16
|
+
],
|
|
17
|
+
'comma-dangle': [
|
|
18
|
+
'error',
|
|
19
|
+
'never',
|
|
20
|
+
],
|
|
9
21
|
'comma-spacing': 'off',
|
|
10
22
|
'function-paren-newline': 'off',
|
|
11
23
|
'no-undef': 'off',
|
|
12
|
-
'eol-last': [
|
|
24
|
+
'eol-last': [
|
|
25
|
+
'error',
|
|
26
|
+
'always',
|
|
27
|
+
],
|
|
13
28
|
'no-multi-spaces': 'off',
|
|
14
29
|
},
|
|
15
30
|
}, {
|
|
16
31
|
files: 'package.json',
|
|
17
32
|
rules: {
|
|
18
|
-
indent: [
|
|
33
|
+
indent: [
|
|
34
|
+
'error',
|
|
35
|
+
2,
|
|
36
|
+
],
|
|
19
37
|
},
|
|
20
38
|
}, {
|
|
21
39
|
files: '*ignore{json}',
|
|
@@ -28,4 +46,3 @@ module.exports = [{
|
|
|
28
46
|
indent: 'off',
|
|
29
47
|
},
|
|
30
48
|
}];
|
|
31
|
-
|
package/lib/jsx.js
CHANGED
|
@@ -20,10 +20,7 @@ const checkNodeSpace = ({text, node}) => {
|
|
|
20
20
|
if (text.includes(`${key}(`))
|
|
21
21
|
return true;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
return true;
|
|
25
|
-
|
|
26
|
-
return false;
|
|
23
|
+
return key_ && text.includes(`${key_}(`);
|
|
27
24
|
};
|
|
28
25
|
|
|
29
26
|
const fixNodeSpace = ({node, text}) => {
|
|
@@ -52,7 +49,10 @@ module.exports.fix = ({node, text}) => {
|
|
|
52
49
|
if (isSwitchStatement(node))
|
|
53
50
|
return fixSwitch(text);
|
|
54
51
|
|
|
55
|
-
return fixNodeSpace({
|
|
52
|
+
return fixNodeSpace({
|
|
53
|
+
node,
|
|
54
|
+
text,
|
|
55
|
+
});
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
module.exports.include = () => [
|
|
@@ -70,7 +70,10 @@ module.exports.filter = ({node, text}) => {
|
|
|
70
70
|
if (isSwitchStatement(node))
|
|
71
71
|
return checkSwitch(text);
|
|
72
72
|
|
|
73
|
-
return checkNodeSpace({
|
|
73
|
+
return checkNodeSpace({
|
|
74
|
+
node,
|
|
75
|
+
text,
|
|
76
|
+
});
|
|
74
77
|
};
|
|
75
78
|
|
|
76
79
|
function checkCatch(text) {
|
|
@@ -93,7 +96,5 @@ function fixCatch(text) {
|
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
function fixSwitch(text) {
|
|
96
|
-
return text
|
|
97
|
-
.replaceAll('switch (', 'switch(');
|
|
99
|
+
return text.replaceAll('switch (', 'switch(');
|
|
98
100
|
}
|
|
99
|
-
|
|
@@ -11,7 +11,9 @@ module.exports.include = () => [
|
|
|
11
11
|
|
|
12
12
|
module.exports.fix = ({text}) => {
|
|
13
13
|
const end = text.indexOf('}') + 1;
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
const startText = text
|
|
16
|
+
.slice(0, end)
|
|
15
17
|
.replace(/,/g, ',\n ')
|
|
16
18
|
.replace('{', '{\n ')
|
|
17
19
|
.replace('}', '\n}');
|
|
@@ -33,10 +35,7 @@ module.exports.filter = ({node}) => {
|
|
|
33
35
|
const isLoc = isCorrectLoc(line, properties);
|
|
34
36
|
const isLength = isCorrectLength(properties);
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
return false;
|
|
38
|
-
|
|
39
|
-
return true;
|
|
38
|
+
return !(isLoc || isLength);
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
function isCorrectLength(properties) {
|
|
@@ -49,4 +48,3 @@ function isCorrectLength(properties) {
|
|
|
49
48
|
|
|
50
49
|
return true;
|
|
51
50
|
}
|
|
52
|
-
|
package/lib/markdown.js
CHANGED
|
@@ -8,7 +8,10 @@ const {jsx} = require('./jsx');
|
|
|
8
8
|
const commonRules = {
|
|
9
9
|
'no-undef': 'off',
|
|
10
10
|
'no-empty': 'off',
|
|
11
|
-
'eol-last': [
|
|
11
|
+
'eol-last': [
|
|
12
|
+
'error',
|
|
13
|
+
'never',
|
|
14
|
+
],
|
|
12
15
|
'no-unreachable': 'off',
|
|
13
16
|
'no-constant-condition': 'off',
|
|
14
17
|
'n/no-extraneous-require': 'off',
|
|
@@ -21,6 +24,7 @@ const commonRules = {
|
|
|
21
24
|
'n/no-unsupported-features/n-builtins': 'off',
|
|
22
25
|
'n/no-process-exit': 'off',
|
|
23
26
|
};
|
|
27
|
+
|
|
24
28
|
const parserOptions = {
|
|
25
29
|
requireConfigFile: false,
|
|
26
30
|
babelOptions: {
|
|
@@ -32,9 +36,7 @@ const parserOptions = {
|
|
|
32
36
|
...parserPlugins,
|
|
33
37
|
],
|
|
34
38
|
},
|
|
35
|
-
plugins: [
|
|
36
|
-
'@babel/plugin-syntax-class-properties',
|
|
37
|
-
],
|
|
39
|
+
plugins: ['@babel/plugin-syntax-class-properties'],
|
|
38
40
|
},
|
|
39
41
|
};
|
|
40
42
|
|
|
@@ -81,7 +83,9 @@ module.exports = [{
|
|
|
81
83
|
}, {
|
|
82
84
|
files: '*.md{json}',
|
|
83
85
|
rules: {
|
|
84
|
-
'eol-last': [
|
|
86
|
+
'eol-last': [
|
|
87
|
+
'error',
|
|
88
|
+
'never',
|
|
89
|
+
],
|
|
85
90
|
},
|
|
86
91
|
}];
|
|
87
|
-
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const {isImportDeclaration} = require('putout').types;
|
|
4
4
|
const {parseImportSpecifiers} = require('parse-import-specifiers');
|
|
5
|
+
|
|
5
6
|
const {
|
|
6
7
|
isCorrectLoc,
|
|
7
8
|
isCorrectImportLoc,
|
|
@@ -12,6 +13,7 @@ module.exports.report = () => 'Keep each property on separate lines when using m
|
|
|
12
13
|
|
|
13
14
|
const parseOptions = (options) => {
|
|
14
15
|
const {minProperties = 2} = options[0] || {};
|
|
16
|
+
|
|
15
17
|
return {
|
|
16
18
|
minProperties,
|
|
17
19
|
};
|
|
@@ -29,6 +31,7 @@ module.exports.include = ({options}) => {
|
|
|
29
31
|
module.exports.filter = ({node}, options) => {
|
|
30
32
|
const {minProperties} = parseOptions(options);
|
|
31
33
|
const {line} = node.loc.start;
|
|
34
|
+
|
|
32
35
|
const {
|
|
33
36
|
id,
|
|
34
37
|
specifiers,
|
|
@@ -59,4 +62,3 @@ module.exports.fix = ({text}) => {
|
|
|
59
62
|
.replace('}', '\n}')
|
|
60
63
|
.replace(/\n\s*?\n/g, '\n');
|
|
61
64
|
};
|
|
62
|
-
|
|
@@ -31,10 +31,7 @@ module.exports.filter = ({node, text}) => {
|
|
|
31
31
|
const isOpenBracket = /^\(\n/.test(textPeace);
|
|
32
32
|
const isCloseBracket = /\n\s*\)$/.test(textPeace);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
return false;
|
|
36
|
-
|
|
37
|
-
return true;
|
|
34
|
+
return !(isOpenBracket && isCloseBracket);
|
|
38
35
|
};
|
|
39
36
|
|
|
40
37
|
module.exports.fix = ({text}) => {
|
|
@@ -43,4 +40,3 @@ module.exports.fix = ({text}) => {
|
|
|
43
40
|
.replace(/,\s?/g, ',\n')
|
|
44
41
|
.replace(/\)$/, '\n)');
|
|
45
42
|
};
|
|
46
|
-
|
|
@@ -20,10 +20,7 @@ module.exports.include = () => [
|
|
|
20
20
|
];
|
|
21
21
|
|
|
22
22
|
module.exports.filter = ({node}) => {
|
|
23
|
-
const {
|
|
24
|
-
loc,
|
|
25
|
-
right,
|
|
26
|
-
} = node;
|
|
23
|
+
const {loc, right} = node;
|
|
27
24
|
|
|
28
25
|
if (isVariableDeclarator(node)) {
|
|
29
26
|
const {init} = node;
|
|
@@ -60,4 +57,3 @@ module.exports.fix = ({text}) => {
|
|
|
60
57
|
.replace(/}/g, '\n}')
|
|
61
58
|
.replace(/\n(\s+)?\n/g, '\n');
|
|
62
59
|
};
|
|
63
|
-
|
|
@@ -8,10 +8,7 @@ const isSameGroup = (a, b) => {
|
|
|
8
8
|
if (isLocal(a) && isLocal(b))
|
|
9
9
|
return true;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
return true;
|
|
13
|
-
|
|
14
|
-
return false;
|
|
11
|
+
return isNode(a) && isNode(b);
|
|
15
12
|
};
|
|
16
13
|
|
|
17
14
|
module.exports = {
|
|
@@ -30,6 +27,7 @@ module.exports = {
|
|
|
30
27
|
ImportDeclaration(node) {
|
|
31
28
|
const source = context.sourceCode;
|
|
32
29
|
const text = source.getText(node);
|
|
30
|
+
|
|
33
31
|
const newline = source
|
|
34
32
|
.getText(node, 0, 2)
|
|
35
33
|
.replace(text, '');
|
|
@@ -10,12 +10,10 @@ module.exports.filter = ({text}) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
module.exports.fix = ({text}) => {
|
|
13
|
-
return text
|
|
14
|
-
.replace(regExp, '\n}');
|
|
13
|
+
return text.replace(regExp, '\n}');
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
module.exports.include = () => [
|
|
18
17
|
'ImportDeclaration',
|
|
19
18
|
'ObjectExpression',
|
|
20
19
|
];
|
|
21
|
-
|
|
@@ -10,12 +10,10 @@ module.exports.filter = ({text}) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
module.exports.fix = ({text}) => {
|
|
13
|
-
return text
|
|
14
|
-
.replace(regExp, '{\n');
|
|
13
|
+
return text.replace(regExp, '{\n');
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
module.exports.include = () => [
|
|
18
17
|
'ImportDeclaration',
|
|
19
18
|
'ObjectExpression',
|
|
20
19
|
];
|
|
21
|
-
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
operator,
|
|
5
|
-
types,
|
|
6
|
-
} = require('putout');
|
|
3
|
+
const {operator, types} = require('putout');
|
|
7
4
|
|
|
8
5
|
const {
|
|
9
6
|
isRestElement,
|
|
@@ -15,9 +12,7 @@ const {
|
|
|
15
12
|
const NewLinesReg = /([\s,]+)?\n(\s+)?/g;
|
|
16
13
|
const AssignRegExp = /{\n?.*=.*\n?.*}/;
|
|
17
14
|
|
|
18
|
-
const {
|
|
19
|
-
compare,
|
|
20
|
-
} = operator;
|
|
15
|
+
const {compare} = operator;
|
|
21
16
|
|
|
22
17
|
module.exports.category = 'destructuring';
|
|
23
18
|
module.exports.report = () => 'Keep curly braces on one line when you have one destructuring property';
|
|
@@ -46,10 +41,7 @@ module.exports.filter = ({node, text, getText, getCommentsInside}) => {
|
|
|
46
41
|
const [property] = node.id.properties;
|
|
47
42
|
const {value} = property;
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
return false;
|
|
51
|
-
|
|
52
|
-
return true;
|
|
44
|
+
return !isAssignmentPattern(value);
|
|
53
45
|
}
|
|
54
46
|
|
|
55
47
|
return false;
|
|
@@ -76,4 +68,3 @@ module.exports.fix = ({text, node, getText}) => {
|
|
|
76
68
|
|
|
77
69
|
return text.replace(idText, `{${key.name}: ${value.name}}`);
|
|
78
70
|
};
|
|
79
|
-
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
operator,
|
|
5
|
-
types,
|
|
6
|
-
} = require('putout');
|
|
3
|
+
const {operator, types} = require('putout');
|
|
7
4
|
|
|
8
5
|
const {
|
|
9
6
|
isCallExpression,
|
|
@@ -38,7 +35,10 @@ module.exports.filter = ({text, node}) => {
|
|
|
38
35
|
break;
|
|
39
36
|
|
|
40
37
|
const {callee} = prev.expression;
|
|
41
|
-
|
|
38
|
+
|
|
39
|
+
return isIdentifier(callee.object, {
|
|
40
|
+
name: 't',
|
|
41
|
+
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return false;
|
|
@@ -51,4 +51,3 @@ module.exports.fix = ({text}) => {
|
|
|
51
51
|
module.exports.include = () => [
|
|
52
52
|
'CallExpression',
|
|
53
53
|
];
|
|
54
|
-
|
package/lib/ts.js
CHANGED
|
@@ -8,25 +8,16 @@ const warnOnUnsupportedTypeScriptVersion = false;
|
|
|
8
8
|
const extensionRules = {
|
|
9
9
|
'no-undef': 'off',
|
|
10
10
|
'no-var': 'off',
|
|
11
|
-
|
|
12
|
-
// putout/object-property-newline instead
|
|
13
|
-
'@typescript-eslint/brace-style': 'off',
|
|
14
|
-
|
|
11
|
+
'@typescript-eslint/brace-style': 'off', // putout/object-property-newline instead
|
|
15
12
|
'comma-dangle': 'off',
|
|
16
13
|
'@typescript-eslint/comma-dangle': rules['comma-dangle'],
|
|
17
14
|
|
|
18
15
|
'comma-spacing': 'off',
|
|
19
16
|
'@typescript-eslint/comma-spacing': 'error',
|
|
20
|
-
|
|
21
|
-
// requires type information
|
|
22
|
-
'@typescript-eslint/dot-notation': 'off',
|
|
23
|
-
|
|
17
|
+
'@typescript-eslint/dot-notation': 'off', // requires type information
|
|
24
18
|
'func-call-spacing': 'off',
|
|
25
19
|
'@typescript-eslint/func-call-spacing': 'error',
|
|
26
|
-
|
|
27
|
-
// broken
|
|
28
|
-
'@typescript-eslint/indent': 'off',
|
|
29
|
-
|
|
20
|
+
'@typescript-eslint/indent': 'off', // broken
|
|
30
21
|
'@typescript-eslint/lines-between-class-members': 'off',
|
|
31
22
|
'@typescript-eslint/no-array-constructor': 'off',
|
|
32
23
|
|
|
@@ -59,7 +50,7 @@ const extensionRules = {
|
|
|
59
50
|
'@typescript-eslint/space-before-function-paren': rules['space-before-function-paren'],
|
|
60
51
|
|
|
61
52
|
'space-infix-ops': 'off',
|
|
62
|
-
'@typescript-eslint/space-infix-ops': rules[
|
|
53
|
+
'@typescript-eslint/space-infix-ops': rules['space-infix-ops'],
|
|
63
54
|
|
|
64
55
|
'no-redecalre': 'off',
|
|
65
56
|
'@typescript-eslint/no-redeclare': 'error',
|
|
@@ -74,12 +65,8 @@ const ts = {
|
|
|
74
65
|
jsx: false,
|
|
75
66
|
},
|
|
76
67
|
},
|
|
77
|
-
plugins: [
|
|
78
|
-
|
|
79
|
-
],
|
|
80
|
-
extends: [
|
|
81
|
-
'plugin:@typescript-eslint/recommended',
|
|
82
|
-
],
|
|
68
|
+
plugins: ['@typescript-eslint'],
|
|
69
|
+
extends: ['plugin:@typescript-eslint/recommended'],
|
|
83
70
|
rules: {
|
|
84
71
|
...extensionRules,
|
|
85
72
|
'putout/no-unresolved': 'off',
|
|
@@ -90,19 +77,17 @@ const ts = {
|
|
|
90
77
|
},
|
|
91
78
|
};
|
|
92
79
|
|
|
93
|
-
module.exports = [
|
|
94
|
-
ts,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
jsx: true,
|
|
102
|
-
},
|
|
80
|
+
module.exports = [ts, {
|
|
81
|
+
...ts,
|
|
82
|
+
...jsx.jsx,
|
|
83
|
+
files: '*.tsx',
|
|
84
|
+
parserOptions: {
|
|
85
|
+
warnOnUnsupportedTypeScriptVersion,
|
|
86
|
+
ecmaFeatures: {
|
|
87
|
+
jsx: true,
|
|
103
88
|
},
|
|
104
89
|
},
|
|
105
|
-
];
|
|
90
|
+
}];
|
|
106
91
|
|
|
107
92
|
function convertPaddingLines([state, ...lines]) {
|
|
108
93
|
const newLines = [];
|
|
@@ -123,6 +108,8 @@ function convertPaddingLines([state, ...lines]) {
|
|
|
123
108
|
});
|
|
124
109
|
}
|
|
125
110
|
|
|
126
|
-
return [
|
|
111
|
+
return [
|
|
112
|
+
state,
|
|
113
|
+
...newLines,
|
|
114
|
+
];
|
|
127
115
|
}
|
|
128
|
-
|
package/lib/yaml.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "ESLint plugin for 🐊Putout",
|
|
6
6
|
"release": false,
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"@babel/plugin-syntax-class-properties": "^7.12.1",
|
|
44
44
|
"@babel/traverse": "^7.16.3",
|
|
45
45
|
"@eslint/eslintrc": "^2.0.2",
|
|
46
|
-
"@putout/engine-parser": "^
|
|
46
|
+
"@putout/engine-parser": "^7.0.0",
|
|
47
47
|
"@putout/eslint": "^2.0.0",
|
|
48
48
|
"@putout/eslint-config": "^7.0.0",
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
50
|
-
"@typescript-eslint/parser": "^
|
|
50
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
51
51
|
"align-spaces": "^1.0.0",
|
|
52
52
|
"eslint-plugin-n": "^16.0.0",
|
|
53
53
|
"eslint-plugin-react": "^7.32.2",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@babel/plugin-syntax-typescript": "^7.12.1",
|
|
60
60
|
"@putout/plugin-eslint-plugin": "*",
|
|
61
|
-
"@putout/test": "^
|
|
62
|
-
"c8": "^
|
|
61
|
+
"@putout/test": "^7.0.0",
|
|
62
|
+
"c8": "^8.0.0",
|
|
63
63
|
"eslint": "^8.0.1",
|
|
64
64
|
"eslint-plugin-eslint-plugin": "^5.0.6",
|
|
65
65
|
"madrun": "^9.0.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"eslint": ">=8.0.0",
|
|
77
|
-
"putout": ">=
|
|
77
|
+
"putout": ">=30"
|
|
78
78
|
},
|
|
79
79
|
"license": "MIT",
|
|
80
80
|
"publishConfig": {
|