flatlint 4.12.0 → 4.13.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,9 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
closeCurlyBrace,
|
|
3
|
+
comma,
|
|
4
|
+
isPunctuator,
|
|
5
|
+
openSquireBrace,
|
|
6
|
+
} from '#types';
|
|
7
|
+
|
|
1
8
|
export const report = () => 'Add missing square brace';
|
|
2
9
|
|
|
10
|
+
const addIndex = (a, i) => [i, a];
|
|
11
|
+
|
|
3
12
|
export const match = () => ({
|
|
4
13
|
'["__a"': (vars, path) => !path.isNext(),
|
|
14
|
+
'[__array;': ({__array}) => {
|
|
15
|
+
const last = __array.at(-1);
|
|
16
|
+
return !isPunctuator(last, closeCurlyBrace);
|
|
17
|
+
},
|
|
18
|
+
'"__a",\n}': (vars, path) => {
|
|
19
|
+
const allPrevs = path
|
|
20
|
+
.getAllPrev()
|
|
21
|
+
.map(addIndex);
|
|
22
|
+
|
|
23
|
+
let is = false;
|
|
24
|
+
|
|
25
|
+
for (const [i, prev] of allPrevs) {
|
|
26
|
+
const COMMA_POSITION = '\n",'.length;
|
|
27
|
+
|
|
28
|
+
if (i === COMMA_POSITION) {
|
|
29
|
+
is = isPunctuator(prev, [comma, openSquireBrace]);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return is;
|
|
35
|
+
},
|
|
5
36
|
});
|
|
6
37
|
export const replace = () => ({
|
|
38
|
+
'"__a",\n}': '"__a",\n]}',
|
|
7
39
|
'[__array;': '[__array];',
|
|
8
40
|
'["__a"': '["__a"];',
|
|
9
41
|
'[;': '[];',
|
|
@@ -12,3 +44,4 @@ export const replace = () => ({
|
|
|
12
44
|
'(__a, [__b)': '(__a, [__b])',
|
|
13
45
|
'(__a, [__b, __c)': '(__a, [__b, __c])',
|
|
14
46
|
});
|
|
47
|
+
|