flatlint 1.93.1 → 1.95.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 +14 -0
- package/README.md +3 -0
- package/lib/plugins/add-missing-round-brace/index.js +36 -2
- package/lib/plugins/add-missing-semicolon/index.js +3 -0
- package/lib/plugins/remove-useless-comma/index.js +5 -1
- package/lib/runner/path.js +13 -3
- package/lib/types/types.js +3 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
2025.02.01, v1.95.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- 8697533 flatlint: add-missing-round-brace: when next keyword
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- 978c283 flatlint: add-missing-round-brace: before semicolon
|
|
8
|
+
|
|
9
|
+
2025.02.01, v1.94.0
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 22555f6 flatlint: remove-useless-comma: exclude property-array
|
|
13
|
+
- 04c24a4 faltlint: add-missing-semicolon: exclude template tail
|
|
14
|
+
|
|
1
15
|
2025.02.01, v1.93.1
|
|
2
16
|
|
|
3
17
|
feature:
|
package/README.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
closeRoundBrace,
|
|
3
|
+
isKeyword,
|
|
4
|
+
isPunctuator,
|
|
5
|
+
openRoundBrace,
|
|
6
|
+
semicolon,
|
|
7
|
+
} from '#types';
|
|
2
8
|
|
|
3
9
|
export const report = () => 'Add missing round brace';
|
|
4
10
|
|
|
5
11
|
export const match = () => ({
|
|
6
|
-
'__a(__args': (
|
|
12
|
+
'__a(__args': ({__args}, path) => {
|
|
13
|
+
const last = __args.at(-1);
|
|
14
|
+
|
|
15
|
+
if (isPunctuator(last, semicolon))
|
|
16
|
+
return false;
|
|
17
|
+
|
|
7
18
|
if (path.isCurrentPunctuator(closeRoundBrace))
|
|
8
19
|
return false;
|
|
9
20
|
|
|
@@ -15,6 +26,26 @@ export const match = () => ({
|
|
|
15
26
|
'{__a} = __expr;': (vars, path) => {
|
|
16
27
|
return !path.isPrevDeclarationKeyword();
|
|
17
28
|
},
|
|
29
|
+
'{__a} = __expr': (vars, path) => {
|
|
30
|
+
return path.isNextKeyword();
|
|
31
|
+
},
|
|
32
|
+
'__a;': (vars, path) => {
|
|
33
|
+
let result = false;
|
|
34
|
+
|
|
35
|
+
for (const current of path.getAllPrev()) {
|
|
36
|
+
if (isPunctuator(current, openRoundBrace)) {
|
|
37
|
+
result = true;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (isKeyword(current)) {
|
|
42
|
+
result = false;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
},
|
|
18
49
|
});
|
|
19
50
|
|
|
20
51
|
export const replace = () => ({
|
|
@@ -24,4 +55,7 @@ export const replace = () => ({
|
|
|
24
55
|
'if (__a(__args) {': 'if (__a(__args)) {',
|
|
25
56
|
'if (__a(__args)': 'if (__a(__args))',
|
|
26
57
|
'{__a} = __expr;': '({__a} = __expr);',
|
|
58
|
+
'{__a} = __expr': '({__a} = __expr)',
|
|
59
|
+
'__a;': '__a);',
|
|
27
60
|
});
|
|
61
|
+
|
|
@@ -57,6 +57,11 @@ export const match = () => ({
|
|
|
57
57
|
return true;
|
|
58
58
|
},
|
|
59
59
|
'],': (vars, path) => {
|
|
60
|
+
for (const token of path.getAllPrev()) {
|
|
61
|
+
if (isPunctuator(token, colon))
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
60
65
|
let result = false;
|
|
61
66
|
|
|
62
67
|
for (const token of path.getAllNext()) {
|
|
@@ -82,4 +87,3 @@ export const replace = () => ({
|
|
|
82
87
|
'}),': '})',
|
|
83
88
|
'],': '];',
|
|
84
89
|
});
|
|
85
|
-
|
package/lib/runner/path.js
CHANGED
|
@@ -42,6 +42,10 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
42
42
|
tokens,
|
|
43
43
|
end,
|
|
44
44
|
}),
|
|
45
|
+
isNextTemplateTail: createIsNextTemplateTail({
|
|
46
|
+
tokens,
|
|
47
|
+
end,
|
|
48
|
+
}),
|
|
45
49
|
isPrevPunctuator: createIsPrevPunctuator({
|
|
46
50
|
tokens,
|
|
47
51
|
start,
|
|
@@ -110,12 +114,18 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
|
110
114
|
end,
|
|
111
115
|
});
|
|
112
116
|
|
|
113
|
-
if (!current)
|
|
114
|
-
return false;
|
|
115
|
-
|
|
116
117
|
return isPunctuator(current, punctuators);
|
|
117
118
|
};
|
|
118
119
|
|
|
120
|
+
const createIsNextTemplateTail = ({tokens, end}) => () => {
|
|
121
|
+
const current = getNext({
|
|
122
|
+
tokens,
|
|
123
|
+
end,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return isTemplateTail(current);
|
|
127
|
+
};
|
|
128
|
+
|
|
119
129
|
const createGetPrev = ({tokens, start}) => () => {
|
|
120
130
|
return getPrev({
|
|
121
131
|
tokens,
|
package/lib/types/types.js
CHANGED