flatlint 2.0.9 → 2.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/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2025.02.28, v2.1.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 0a5ca63 flatlint: convert-semicolon-to-comma: call
|
|
5
|
+
- 84b03a9 flatlint: @putout/test v12.0.1
|
|
6
|
+
- 38ecf70 flatlint: eslint-plugin-putout v25.0.2
|
|
7
|
+
|
|
8
|
+
2025.02.21, v2.0.10
|
|
9
|
+
|
|
10
|
+
fix:
|
|
11
|
+
- 16f5d44 flatlint: add-missing-comma: before broken quote
|
|
12
|
+
|
|
1
13
|
2025.02.21, v2.0.9
|
|
2
14
|
|
|
3
15
|
feature:
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
closeSquareBrace,
|
|
3
|
+
colon,
|
|
3
4
|
isOneOfKeywords,
|
|
4
5
|
isPunctuator,
|
|
5
6
|
} from '#types';
|
|
6
7
|
|
|
8
|
+
const keywords = [
|
|
9
|
+
'readonly',
|
|
10
|
+
'static',
|
|
11
|
+
'implements',
|
|
12
|
+
'interface',
|
|
13
|
+
'class',
|
|
14
|
+
];
|
|
15
|
+
|
|
7
16
|
export const report = () => `Use ',' instead of ';'`;
|
|
8
17
|
|
|
9
18
|
export const match = () => ({
|
|
@@ -12,12 +21,7 @@ export const match = () => ({
|
|
|
12
21
|
return false;
|
|
13
22
|
|
|
14
23
|
for (const token of path.getAllPrev()) {
|
|
15
|
-
if (isOneOfKeywords(token,
|
|
16
|
-
'readonly',
|
|
17
|
-
'static',
|
|
18
|
-
'implements',
|
|
19
|
-
'interface',
|
|
20
|
-
]))
|
|
24
|
+
if (isOneOfKeywords(token, keywords))
|
|
21
25
|
return false;
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -25,27 +29,40 @@ export const match = () => ({
|
|
|
25
29
|
if (isPunctuator(token, closeSquareBrace))
|
|
26
30
|
return true;
|
|
27
31
|
}
|
|
32
|
+
|
|
33
|
+
return false;
|
|
28
34
|
},
|
|
29
35
|
'__a: __expr;': (vars, path) => {
|
|
30
36
|
if (path.isPrevDeclarationKeyword())
|
|
31
37
|
return false;
|
|
32
38
|
|
|
33
|
-
const keywords = [
|
|
34
|
-
'class',
|
|
35
|
-
'readonly',
|
|
36
|
-
'static',
|
|
37
|
-
'implements',
|
|
38
|
-
];
|
|
39
|
-
|
|
40
39
|
for (const token of path.getAllPrev())
|
|
41
40
|
if (isOneOfKeywords(token, keywords))
|
|
42
41
|
return false;
|
|
43
42
|
|
|
44
43
|
return true;
|
|
45
44
|
},
|
|
45
|
+
');': (vars, path) => {
|
|
46
|
+
if (!path.isNext())
|
|
47
|
+
return false;
|
|
48
|
+
|
|
49
|
+
for (const token of path.getAllPrev()) {
|
|
50
|
+
if (isOneOfKeywords(token, keywords))
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const token of path.getAllPrev()) {
|
|
55
|
+
if (isPunctuator(token, colon))
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return false;
|
|
60
|
+
},
|
|
46
61
|
});
|
|
47
62
|
|
|
48
63
|
export const replace = () => ({
|
|
49
64
|
'__a: __expr;': '__a: __expr,',
|
|
50
65
|
'__a;': '__a,',
|
|
66
|
+
');': '),',
|
|
51
67
|
});
|
|
68
|
+
|
package/lib/runner/path.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {prepare} from '#parser';
|
|
1
2
|
import {
|
|
2
3
|
isIdentifier,
|
|
3
4
|
isKeyword,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
isNewLine,
|
|
12
13
|
isWhiteSpace,
|
|
13
14
|
} from '#types';
|
|
15
|
+
import {equal} from '../compare/equal.js';
|
|
14
16
|
|
|
15
17
|
export const createPath = ({tokens, start, end}) => ({
|
|
16
18
|
tokens,
|
|
@@ -44,6 +46,10 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
44
46
|
tokens,
|
|
45
47
|
end,
|
|
46
48
|
}),
|
|
49
|
+
isNextCompare: createIsNextCompare({
|
|
50
|
+
tokens,
|
|
51
|
+
end,
|
|
52
|
+
}),
|
|
47
53
|
isNextDeclarationKeyword: createIsNextDeclarationKeyword({
|
|
48
54
|
tokens,
|
|
49
55
|
end,
|
|
@@ -214,3 +220,26 @@ const createGetAllNext = ({tokens, end}) => function*() {
|
|
|
214
220
|
/* c8 ignore start */
|
|
215
221
|
/* c8 ignore end */
|
|
216
222
|
};
|
|
223
|
+
|
|
224
|
+
const createIsNextCompare = ({tokens, end}) => (template) => {
|
|
225
|
+
const getAllNext = createGetAllNext({
|
|
226
|
+
tokens,
|
|
227
|
+
end,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const n = template.length;
|
|
231
|
+
const templateTokens = prepare(template);
|
|
232
|
+
let i = 0;
|
|
233
|
+
|
|
234
|
+
for (const token of getAllNext()) {
|
|
235
|
+
if (i === n)
|
|
236
|
+
break;
|
|
237
|
+
|
|
238
|
+
if (!equal(token, templateTokens[i]))
|
|
239
|
+
return false;
|
|
240
|
+
|
|
241
|
+
++i;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return true;
|
|
245
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flatlint",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "JavaScript tokens-based linter",
|
|
5
5
|
"main": "lib/flatlint.js",
|
|
6
6
|
"type": "module",
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@putout/eslint-flat": "^2.0.0",
|
|
90
90
|
"@putout/formatter-json": "^2.0.0",
|
|
91
|
-
"@putout/test": "^
|
|
91
|
+
"@putout/test": "^12.0.1",
|
|
92
92
|
"c8": "^10.1.2",
|
|
93
93
|
"eslint": "^9.7.0",
|
|
94
|
-
"eslint-plugin-putout": "^
|
|
94
|
+
"eslint-plugin-putout": "^25.0.2",
|
|
95
95
|
"madrun": "^10.2.2",
|
|
96
96
|
"mock-require": "^3.0.3",
|
|
97
97
|
"montag": "^1.0.0",
|