flatlint 1.85.0 → 1.87.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,16 @@
|
|
|
1
|
+
2025.01.29, v1.87.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- f299df8 flatlint: add-missing-round-brace: method
|
|
5
|
+
|
|
6
|
+
2025.01.28, v1.86.0
|
|
7
|
+
|
|
8
|
+
fix:
|
|
9
|
+
- f3df7fa flatlint: add-missing-semicolon: exclude: if
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- da300c1 flatlint: add-missing-round-brace: break
|
|
13
|
+
|
|
1
14
|
2025.01.28, v1.85.0
|
|
2
15
|
|
|
3
16
|
feature:
|
|
@@ -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,21 +1,17 @@
|
|
|
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
|
|
|
17
10
|
return !path.isNextPunctuator(closeRoundBrace);
|
|
18
11
|
},
|
|
12
|
+
'if (__a(__args)': (vars, path) => {
|
|
13
|
+
return path.isNextKeyword();
|
|
14
|
+
},
|
|
19
15
|
});
|
|
20
16
|
|
|
21
17
|
export const replace = () => ({
|
|
@@ -23,4 +19,5 @@ export const replace = () => ({
|
|
|
23
19
|
'__a(__args': '__a(__args)',
|
|
24
20
|
'if (__a.__b(__args) {': 'if (__a.__b(__args)) {',
|
|
25
21
|
'if (__a(__args) {': 'if (__a(__args)) {',
|
|
22
|
+
'if (__a(__args)': 'if (__a(__args))',
|
|
26
23
|
});
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
question,
|
|
8
8
|
closeCurlyBrace,
|
|
9
9
|
isOnlyWhitespaces,
|
|
10
|
+
isKeyword,
|
|
10
11
|
} from '#types';
|
|
11
12
|
|
|
12
13
|
export const report = () => 'Add missing semicolon';
|
|
@@ -35,6 +36,11 @@ export const match = () => ({
|
|
|
35
36
|
if (path.isInsideTemplate())
|
|
36
37
|
return false;
|
|
37
38
|
|
|
39
|
+
for (const current of path.getAllPrev()) {
|
|
40
|
+
if (isKeyword(current, 'if'))
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
return !path.isPrevIdentifier('function');
|
|
39
45
|
},
|
|
40
46
|
'})': (vars, 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
|
}
|