flatlint 2.12.0 → 2.14.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
|
@@ -8,19 +8,10 @@ import {
|
|
|
8
8
|
export const report = () => 'Add missing comma';
|
|
9
9
|
|
|
10
10
|
export const match = () => ({
|
|
11
|
-
'
|
|
12
|
-
if (path.
|
|
13
|
-
return true;
|
|
14
|
-
|
|
15
|
-
if (path.isNextKeyword())
|
|
16
|
-
return false;
|
|
17
|
-
|
|
18
|
-
if (path.isPrevPunctuator(assign))
|
|
11
|
+
'__a': ({__a}, path) => {
|
|
12
|
+
if (path.isNextTemplateHead())
|
|
19
13
|
return false;
|
|
20
14
|
|
|
21
|
-
return path.isNextIdentifier();
|
|
22
|
-
},
|
|
23
|
-
'__a': ({__a}, path) => {
|
|
24
15
|
const isType = isKeyword(__a, 'type');
|
|
25
16
|
|
|
26
17
|
if (isType && path.isNextCompare('__a ='))
|
|
@@ -46,6 +37,18 @@ export const match = () => ({
|
|
|
46
37
|
|
|
47
38
|
return !path.isNextPunctuator();
|
|
48
39
|
},
|
|
40
|
+
'"__a"': (vars, path) => {
|
|
41
|
+
if (path.isNextPunctuator(quote))
|
|
42
|
+
return true;
|
|
43
|
+
|
|
44
|
+
if (path.isNextKeyword())
|
|
45
|
+
return false;
|
|
46
|
+
|
|
47
|
+
if (path.isPrevPunctuator(assign))
|
|
48
|
+
return false;
|
|
49
|
+
|
|
50
|
+
return path.isNextIdentifier();
|
|
51
|
+
},
|
|
49
52
|
});
|
|
50
53
|
|
|
51
54
|
export const replace = () => ({
|
|
@@ -68,7 +68,13 @@ export const match = () => ({
|
|
|
68
68
|
if (isOneOfKeywords(token, keywords))
|
|
69
69
|
return false;
|
|
70
70
|
|
|
71
|
-
if (isPunctuator(token, [
|
|
71
|
+
if (isPunctuator(token, [
|
|
72
|
+
assign,
|
|
73
|
+
bitwiseAnd,
|
|
74
|
+
dot,
|
|
75
|
+
semicolon,
|
|
76
|
+
closeSquareBrace,
|
|
77
|
+
]))
|
|
72
78
|
return false;
|
|
73
79
|
|
|
74
80
|
if (isPunctuator(token, colon) && !isNextCall)
|
|
@@ -88,4 +94,3 @@ export const replace = () => ({
|
|
|
88
94
|
');': '),',
|
|
89
95
|
'__a];': '__a],',
|
|
90
96
|
});
|
|
91
|
-
|
package/lib/runner/path.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
isDeclarationKeyword,
|
|
12
12
|
isNewLine,
|
|
13
13
|
isWhiteSpace,
|
|
14
|
+
isTemplateHead,
|
|
14
15
|
} from '#types';
|
|
15
16
|
import {equalTemplate} from '../compare/equal.js';
|
|
16
17
|
|
|
@@ -58,6 +59,10 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
58
59
|
tokens,
|
|
59
60
|
end,
|
|
60
61
|
}),
|
|
62
|
+
isNextTemplateHead: createIsNextTemplateHead({
|
|
63
|
+
tokens,
|
|
64
|
+
end,
|
|
65
|
+
}),
|
|
61
66
|
isNextTemplateTail: createIsNextTemplateTail({
|
|
62
67
|
tokens,
|
|
63
68
|
end,
|
|
@@ -152,12 +157,21 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
|
152
157
|
};
|
|
153
158
|
|
|
154
159
|
const createIsNextTemplateTail = ({tokens, end}) => () => {
|
|
155
|
-
const
|
|
160
|
+
const next = getNext({
|
|
161
|
+
tokens,
|
|
162
|
+
end,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return isTemplateTail(next);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const createIsNextTemplateHead = ({tokens, end}) => () => {
|
|
169
|
+
const next = getNext({
|
|
156
170
|
tokens,
|
|
157
171
|
end,
|
|
158
172
|
});
|
|
159
173
|
|
|
160
|
-
return
|
|
174
|
+
return isTemplateHead(next);
|
|
161
175
|
};
|
|
162
176
|
|
|
163
177
|
const createGetPrev = ({tokens, start}) => () => {
|
package/lib/types/types.js
CHANGED
|
@@ -20,6 +20,7 @@ const isString = (a) => typeof a === 'string';
|
|
|
20
20
|
|
|
21
21
|
export const isTemplateMiddle = (a) => a?.type === 'TemplateMiddle';
|
|
22
22
|
export const isNoSubstitutionTemplate = (a) => a?.type === 'NoSubstitutionTemplate';
|
|
23
|
+
export const isTemplateHead = (a) => a?.type === 'TemplateHead';
|
|
23
24
|
export const isTemplateTail = (a) => a?.type === 'TemplateTail';
|
|
24
25
|
export const isWhiteSpace = ({type}) => type === 'WhiteSpace';
|
|
25
26
|
export const isIdentifier = (token, newToken) => {
|