flatlint 2.0.9 → 2.0.10
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/plugins/add-missing-comma/index.js +3 -0
- package/lib/runner/path.js +29 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
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
|
+
};
|