flatlint 1.84.0 → 1.85.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 +5 -0
- package/lib/compare/collect-args.js +13 -1
- package/lib/runner/path.js +8 -46
- package/lib/types/types.js +35 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
closeCurlyBrace,
|
|
3
3
|
closeRoundBrace,
|
|
4
|
+
isIdentifier,
|
|
4
5
|
isNewLine,
|
|
5
6
|
isOneOfPunctuators,
|
|
7
|
+
getNext,
|
|
6
8
|
NOT_OK,
|
|
7
9
|
OK,
|
|
8
10
|
openCurlyBrace,
|
|
@@ -37,8 +39,18 @@ export const collectArgs = ({currentTokenIndex, tokens}) => {
|
|
|
37
39
|
if (equal(token, openCurlyBrace))
|
|
38
40
|
++curlyBracesBalance;
|
|
39
41
|
|
|
40
|
-
if (equal(token, closeCurlyBrace))
|
|
42
|
+
if (equal(token, closeCurlyBrace)) {
|
|
41
43
|
--curlyBracesBalance;
|
|
44
|
+
const next = getNext({
|
|
45
|
+
tokens,
|
|
46
|
+
end: index + 1,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (isIdentifier(next)) {
|
|
50
|
+
++index;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
42
54
|
|
|
43
55
|
if (curlyBracesBalance < 0)
|
|
44
56
|
break;
|
package/lib/runner/path.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isIdentifier,
|
|
3
|
-
isNewLine,
|
|
4
3
|
isKeyword,
|
|
5
4
|
isPunctuator,
|
|
6
|
-
isWhiteSpace,
|
|
7
5
|
isTemplateTail,
|
|
8
6
|
isTemplateMiddle,
|
|
9
7
|
isNoSubstitutionTemplate,
|
|
8
|
+
getNext,
|
|
9
|
+
getPrev,
|
|
10
10
|
} from '#types';
|
|
11
11
|
|
|
12
12
|
export const createPath = ({tokens, start, end}) => ({
|
|
@@ -51,53 +51,15 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
51
51
|
}),
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
const next = ({tokens, end}) => {
|
|
55
|
-
let i = end - 1;
|
|
56
|
-
|
|
57
|
-
while (++i) {
|
|
58
|
-
const token = tokens[i];
|
|
59
|
-
|
|
60
|
-
if (!token)
|
|
61
|
-
return token;
|
|
62
|
-
|
|
63
|
-
if (isNewLine(token))
|
|
64
|
-
continue;
|
|
65
|
-
|
|
66
|
-
if (isWhiteSpace(token))
|
|
67
|
-
continue;
|
|
68
|
-
|
|
69
|
-
return token;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const prev = ({tokens, start}) => {
|
|
74
|
-
let i = start;
|
|
75
|
-
|
|
76
|
-
while (--i) {
|
|
77
|
-
const token = tokens[i];
|
|
78
|
-
|
|
79
|
-
if (!token)
|
|
80
|
-
return token;
|
|
81
|
-
|
|
82
|
-
if (isNewLine(token))
|
|
83
|
-
continue;
|
|
84
|
-
|
|
85
|
-
if (isWhiteSpace(token))
|
|
86
|
-
continue;
|
|
87
|
-
|
|
88
|
-
return token;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
54
|
const createIsNext = ({tokens, end}) => () => {
|
|
93
|
-
return Boolean(
|
|
55
|
+
return Boolean(getNext({
|
|
94
56
|
tokens,
|
|
95
57
|
end,
|
|
96
58
|
}));
|
|
97
59
|
};
|
|
98
60
|
|
|
99
61
|
const createIsNextIdentifier = ({tokens, end}) => (value) => {
|
|
100
|
-
const current =
|
|
62
|
+
const current = getNext({
|
|
101
63
|
tokens,
|
|
102
64
|
end,
|
|
103
65
|
});
|
|
@@ -106,7 +68,7 @@ const createIsNextIdentifier = ({tokens, end}) => (value) => {
|
|
|
106
68
|
};
|
|
107
69
|
|
|
108
70
|
const createIsInsideTemplate = ({tokens, end}) => () => {
|
|
109
|
-
const current =
|
|
71
|
+
const current = getNext({
|
|
110
72
|
tokens,
|
|
111
73
|
end,
|
|
112
74
|
});
|
|
@@ -121,7 +83,7 @@ const createIsInsideTemplate = ({tokens, end}) => () => {
|
|
|
121
83
|
};
|
|
122
84
|
|
|
123
85
|
const createIsNextKeyword = ({tokens, end}) => () => {
|
|
124
|
-
const current =
|
|
86
|
+
const current = getNext({
|
|
125
87
|
tokens,
|
|
126
88
|
end,
|
|
127
89
|
});
|
|
@@ -130,7 +92,7 @@ const createIsNextKeyword = ({tokens, end}) => () => {
|
|
|
130
92
|
};
|
|
131
93
|
|
|
132
94
|
const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
133
|
-
const current =
|
|
95
|
+
const current = getNext({
|
|
134
96
|
tokens,
|
|
135
97
|
end,
|
|
136
98
|
});
|
|
@@ -142,7 +104,7 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
|
142
104
|
};
|
|
143
105
|
|
|
144
106
|
const createIsPrevPunctuator = ({tokens, start}) => (punctuators) => {
|
|
145
|
-
const current =
|
|
107
|
+
const current = getPrev({
|
|
146
108
|
tokens,
|
|
147
109
|
start,
|
|
148
110
|
});
|
package/lib/types/types.js
CHANGED
|
@@ -9,6 +9,9 @@ export const isNoSubstitutionTemplate = (a) => a?.type === 'NoSubstitutionTempla
|
|
|
9
9
|
export const isTemplateTail = (a) => a?.type === 'TemplateTail';
|
|
10
10
|
export const isWhiteSpace = ({type}) => type === 'WhiteSpace';
|
|
11
11
|
export const isIdentifier = (token, newToken) => {
|
|
12
|
+
if (!token)
|
|
13
|
+
return false;
|
|
14
|
+
|
|
12
15
|
const {type} = token;
|
|
13
16
|
const is = type === 'IdentifierName';
|
|
14
17
|
|
|
@@ -192,3 +195,35 @@ export const isBalancedRoundBraces = (tokens) => {
|
|
|
192
195
|
|
|
193
196
|
return !roundBalance;
|
|
194
197
|
};
|
|
198
|
+
|
|
199
|
+
export const getNext = ({tokens, end}) => {
|
|
200
|
+
let i = end - 1;
|
|
201
|
+
|
|
202
|
+
while (++i) {
|
|
203
|
+
const token = tokens[i];
|
|
204
|
+
|
|
205
|
+
if (!token)
|
|
206
|
+
return token;
|
|
207
|
+
|
|
208
|
+
if (isNewLine(token))
|
|
209
|
+
continue;
|
|
210
|
+
|
|
211
|
+
if (isWhiteSpace(token))
|
|
212
|
+
continue;
|
|
213
|
+
|
|
214
|
+
return token;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export const getPrev = ({tokens, start}) => {
|
|
219
|
+
let i = start;
|
|
220
|
+
|
|
221
|
+
while (--i) {
|
|
222
|
+
const token = tokens[i];
|
|
223
|
+
|
|
224
|
+
if (!token)
|
|
225
|
+
return token;
|
|
226
|
+
|
|
227
|
+
return token;
|
|
228
|
+
}
|
|
229
|
+
};
|