flatlint 1.35.0 → 1.36.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
|
@@ -5,19 +5,20 @@ import {
|
|
|
5
5
|
arrow,
|
|
6
6
|
openCurlyBrace,
|
|
7
7
|
closeRoundBrace,
|
|
8
|
+
dot,
|
|
8
9
|
} from '#types';
|
|
9
10
|
|
|
10
11
|
export const report = () => 'Add missing semicolon';
|
|
11
12
|
|
|
12
13
|
export const match = () => ({
|
|
13
14
|
'const __a = __expr': (vars, path) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const punctuators = [
|
|
16
|
+
comma,
|
|
17
|
+
semicolon,
|
|
18
|
+
openCurlyBrace,
|
|
19
|
+
];
|
|
19
20
|
|
|
20
|
-
if (path.isNextPunctuator(
|
|
21
|
+
if (path.isNextPunctuator(punctuators))
|
|
21
22
|
return false;
|
|
22
23
|
|
|
23
24
|
for (const token of path.getAllNext()) {
|
|
@@ -34,21 +35,18 @@ export const match = () => ({
|
|
|
34
35
|
arrow,
|
|
35
36
|
closeRoundBrace,
|
|
36
37
|
openCurlyBrace,
|
|
38
|
+
dot,
|
|
37
39
|
];
|
|
38
40
|
|
|
39
41
|
if (path.isNextPunctuator(punctuators))
|
|
40
42
|
return false;
|
|
41
43
|
|
|
42
|
-
if (path.isNextPunctuator(openCurlyBrace))
|
|
43
|
-
return false;
|
|
44
|
-
|
|
45
44
|
return !path.isPrevIdentifier('function');
|
|
46
45
|
},
|
|
47
46
|
'})': (vars, path) => {
|
|
48
|
-
|
|
49
|
-
return false;
|
|
47
|
+
const punctuators = [arrow, comma];
|
|
50
48
|
|
|
51
|
-
if (path.isNextPunctuator(
|
|
49
|
+
if (path.isNextPunctuator(punctuators))
|
|
52
50
|
return false;
|
|
53
51
|
|
|
54
52
|
return !path.isNextPunctuator(semicolon);
|
package/lib/runner/path.js
CHANGED
|
@@ -41,12 +41,33 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
41
41
|
tokens,
|
|
42
42
|
start,
|
|
43
43
|
}),
|
|
44
|
+
isPrevPunctuator: createIsPrevPunctuator({
|
|
45
|
+
tokens,
|
|
46
|
+
start,
|
|
47
|
+
end,
|
|
48
|
+
}),
|
|
44
49
|
isCurrentPunctuator: createIsNextPunctuator({
|
|
45
50
|
tokens,
|
|
46
51
|
end: end - 1,
|
|
47
52
|
}),
|
|
48
53
|
});
|
|
49
54
|
|
|
55
|
+
const prev = ({tokens, start, end}) => {
|
|
56
|
+
let i = end + 1;
|
|
57
|
+
|
|
58
|
+
while (--i >= start) {
|
|
59
|
+
const token = tokens[i];
|
|
60
|
+
|
|
61
|
+
if (isNewLine(token))
|
|
62
|
+
continue;
|
|
63
|
+
|
|
64
|
+
if (isWhiteSpace(token))
|
|
65
|
+
continue;
|
|
66
|
+
|
|
67
|
+
return token;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
50
71
|
const next = ({tokens, end}) => {
|
|
51
72
|
let i = end - 1;
|
|
52
73
|
|
|
@@ -108,6 +129,24 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
|
108
129
|
return false;
|
|
109
130
|
};
|
|
110
131
|
|
|
132
|
+
const createIsPrevPunctuator = ({tokens, start, end}) => (punctuators) => {
|
|
133
|
+
const current = prev({
|
|
134
|
+
tokens,
|
|
135
|
+
start,
|
|
136
|
+
end,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (!current)
|
|
140
|
+
return false;
|
|
141
|
+
|
|
142
|
+
for (const punctuator of maybeArray(punctuators)) {
|
|
143
|
+
if (isPunctuator(current, punctuator))
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return false;
|
|
148
|
+
};
|
|
149
|
+
|
|
111
150
|
const createIsPrevIdentifier = ({tokens, start}) => (value) => {
|
|
112
151
|
const SPACE = 1;
|
|
113
152
|
const FUNCTION = 1;
|
|
@@ -135,4 +174,3 @@ const createGetAllNext = ({tokens, end}) => function*() {
|
|
|
135
174
|
yield current;
|
|
136
175
|
}
|
|
137
176
|
};
|
|
138
|
-
|
package/lib/types/types.js
CHANGED
|
@@ -96,14 +96,14 @@ export const isTemplateArgsToken = (a) => isIdentifier(a) && isTemplateArgs(a.va
|
|
|
96
96
|
export const arrow = Punctuator('=>');
|
|
97
97
|
export const closeRoundBrace = Punctuator(')');
|
|
98
98
|
export const closeSquareBrace = Punctuator(']');
|
|
99
|
+
export const colon = Punctuator(':');
|
|
100
|
+
export const comma = Punctuator(',');
|
|
101
|
+
export const dot = Punctuator('.');
|
|
99
102
|
export const openRoundBrace = Punctuator('(');
|
|
100
103
|
export const semicolon = Punctuator(';');
|
|
101
|
-
export const comma = Punctuator(',');
|
|
102
|
-
export const colon = Punctuator(':');
|
|
103
104
|
export const openCurlyBrace = Punctuator('{');
|
|
104
105
|
export const closeCurlyBrace = Punctuator('}');
|
|
105
106
|
export const openSquireBrace = Punctuator('[');
|
|
106
|
-
export const closeSquireBrace = Punctuator(']');
|
|
107
107
|
export const quote = Punctuator(`'`);
|
|
108
108
|
|
|
109
109
|
export const OK = true;
|