flatlint 1.86.0 → 1.88.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/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2025.01.29, v1.88.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- da74764 flatlint: convert-comma-to-semicolon: strict mode
|
|
5
|
+
- 3050f21 flatlint: eslint-plugin-putout v24.0.0
|
|
6
|
+
- a3bc440 flatlint: putout v38.0.0
|
|
7
|
+
|
|
8
|
+
2025.01.29, v1.87.0
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- f299df8 flatlint: add-missing-round-brace: method
|
|
12
|
+
|
|
1
13
|
2025.01.28, v1.86.0
|
|
2
14
|
|
|
3
15
|
fix:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
colon,
|
|
3
|
+
isIdentifier,
|
|
3
4
|
isOneOfKeywords,
|
|
4
5
|
isPunctuator,
|
|
5
6
|
openCurlyBrace,
|
|
@@ -9,18 +10,18 @@ export const report = () => `Add missing '=>'`;
|
|
|
9
10
|
|
|
10
11
|
export const match = () => ({
|
|
11
12
|
'(__args) {': (vars, path) => {
|
|
12
|
-
|
|
13
|
-
if (isPunctuator(current, colon))
|
|
14
|
-
return true;
|
|
15
|
-
|
|
16
|
-
if (isPunctuator(current, openCurlyBrace))
|
|
17
|
-
return false;
|
|
18
|
-
|
|
19
|
-
if (isOneOfKeywords(current, ['if', 'function']))
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
13
|
+
const current = path.getPrev();
|
|
22
14
|
|
|
23
|
-
|
|
15
|
+
if (isOneOfKeywords(current, ['if', 'function']))
|
|
16
|
+
return false;
|
|
17
|
+
|
|
18
|
+
if (isIdentifier(current))
|
|
19
|
+
return false;
|
|
20
|
+
|
|
21
|
+
if (isPunctuator(current, colon))
|
|
22
|
+
return true;
|
|
23
|
+
|
|
24
|
+
return !isPunctuator(current, openCurlyBrace);
|
|
24
25
|
},
|
|
25
26
|
});
|
|
26
27
|
export const replace = () => ({
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
closeRoundBrace,
|
|
3
|
-
isLastPunctuator,
|
|
4
|
-
semicolon,
|
|
5
|
-
} from '#types';
|
|
1
|
+
import {closeRoundBrace} from '#types';
|
|
6
2
|
|
|
7
3
|
export const report = () => 'Add missing round brace';
|
|
8
4
|
|
|
9
5
|
export const match = () => ({
|
|
10
|
-
'__a(__args': (
|
|
11
|
-
if (isLastPunctuator(__args, semicolon))
|
|
12
|
-
return false;
|
|
13
|
-
|
|
6
|
+
'__a(__args': (vars, path) => {
|
|
14
7
|
if (path.isCurrentPunctuator(closeRoundBrace))
|
|
15
8
|
return false;
|
|
16
9
|
|
|
@@ -45,6 +45,12 @@ export const match = () => ({
|
|
|
45
45
|
|
|
46
46
|
return !path.isNextPunctuator([quote, openCurlyBrace]);
|
|
47
47
|
},
|
|
48
|
+
'"__a",': (vars, path) => {
|
|
49
|
+
if (path.isNextPunctuator())
|
|
50
|
+
return false;
|
|
51
|
+
|
|
52
|
+
return path.isNextKeyword();
|
|
53
|
+
},
|
|
48
54
|
});
|
|
49
55
|
|
|
50
56
|
export const replace = () => ({
|
|
@@ -54,6 +60,7 @@ export const replace = () => ({
|
|
|
54
60
|
'__a(__args),': '__a(__args);',
|
|
55
61
|
'return __expr,': 'return __expr;',
|
|
56
62
|
'__a.__b = __expr,': '__a.__b = __expr;',
|
|
63
|
+
'"__a",': '"__a";',
|
|
57
64
|
});
|
|
58
65
|
|
|
59
66
|
const check = ({__x}, path) => {
|
package/lib/runner/path.js
CHANGED
|
@@ -21,6 +21,10 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
21
21
|
tokens,
|
|
22
22
|
start,
|
|
23
23
|
}),
|
|
24
|
+
getPrev: createGetPrev({
|
|
25
|
+
tokens,
|
|
26
|
+
start,
|
|
27
|
+
}),
|
|
24
28
|
isNextKeyword: createIsNextKeyword({
|
|
25
29
|
tokens,
|
|
26
30
|
end,
|
|
@@ -103,6 +107,13 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
|
103
107
|
return isPunctuator(current, punctuators);
|
|
104
108
|
};
|
|
105
109
|
|
|
110
|
+
const createGetPrev = ({tokens, start}) => () => {
|
|
111
|
+
return getPrev({
|
|
112
|
+
tokens,
|
|
113
|
+
start,
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
106
117
|
const createIsPrevPunctuator = ({tokens, start}) => (punctuators) => {
|
|
107
118
|
const current = getPrev({
|
|
108
119
|
tokens,
|
package/lib/types/types.js
CHANGED
|
@@ -31,15 +31,6 @@ export const isNumericLiteral = ({type}) => type === 'NumericLiteral';
|
|
|
31
31
|
export const isNewLine = ({type}) => type === 'LineTerminatorSequence';
|
|
32
32
|
export const notWhiteSpace = (a) => !isWhiteSpace(a);
|
|
33
33
|
|
|
34
|
-
export const isLastPunctuator = (tokens, punctuator) => {
|
|
35
|
-
if (!tokens.length)
|
|
36
|
-
return false;
|
|
37
|
-
|
|
38
|
-
const last = tokens.at(-1);
|
|
39
|
-
|
|
40
|
-
return isPunctuator(last, punctuator);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
34
|
export const isKeyword = (token, name) => {
|
|
44
35
|
if (!token)
|
|
45
36
|
return false;
|
|
@@ -218,11 +209,11 @@ export const getNext = ({tokens, end}) => {
|
|
|
218
209
|
export const getPrev = ({tokens, start}) => {
|
|
219
210
|
let i = start;
|
|
220
211
|
|
|
221
|
-
while (--i) {
|
|
212
|
+
while (--i > -1) {
|
|
222
213
|
const token = tokens[i];
|
|
223
214
|
|
|
224
|
-
if (
|
|
225
|
-
|
|
215
|
+
if (isWhiteSpace(token))
|
|
216
|
+
continue;
|
|
226
217
|
|
|
227
218
|
return token;
|
|
228
219
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flatlint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.88.0",
|
|
4
4
|
"description": "JavaScript tokens-based linter",
|
|
5
5
|
"main": "lib/flatlint.js",
|
|
6
6
|
"type": "module",
|
|
@@ -86,17 +86,17 @@
|
|
|
86
86
|
"js-tokens": "^9.0.1"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"montag": "^1.0.0",
|
|
90
89
|
"@putout/eslint-flat": "^2.0.0",
|
|
91
90
|
"@putout/formatter-json": "^2.0.0",
|
|
92
91
|
"@putout/test": "^11.1.0",
|
|
93
92
|
"c8": "^10.1.2",
|
|
94
93
|
"eslint": "^9.7.0",
|
|
95
|
-
"eslint-plugin-putout": "^
|
|
94
|
+
"eslint-plugin-putout": "^24.0.0",
|
|
96
95
|
"madrun": "^10.2.2",
|
|
97
96
|
"mock-require": "^3.0.3",
|
|
97
|
+
"montag": "^1.0.0",
|
|
98
98
|
"nodemon": "^3.0.1",
|
|
99
|
-
"putout": "^
|
|
99
|
+
"putout": "^38.0.0",
|
|
100
100
|
"supertape": "^10.0.0"
|
|
101
101
|
},
|
|
102
102
|
"publishConfig": {
|