flatlint 2.14.0 → 2.14.1
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 +2 -2
- package/lib/plugins/add-missing-arrow/index.js +2 -2
- package/lib/plugins/add-missing-assign/index.js +3 -3
- package/lib/plugins/convert-comma-to-semicolon/index.js +3 -4
- package/lib/plugins/convert-semicolon-to-comma/index.js +4 -4
- package/lib/types/types.js +2 -11
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
closeCurlyBrace,
|
|
3
3
|
closeRoundBrace,
|
|
4
4
|
isNewLine,
|
|
5
|
-
|
|
5
|
+
isPunctuator,
|
|
6
6
|
NOT_OK,
|
|
7
7
|
OK,
|
|
8
8
|
openCurlyBrace,
|
|
@@ -19,7 +19,7 @@ export const collectArgs = ({currentTokenIndex, tokens}) => {
|
|
|
19
19
|
const n = tokens.length;
|
|
20
20
|
const currentToken = tokens[index];
|
|
21
21
|
|
|
22
|
-
if (
|
|
22
|
+
if (isPunctuator(currentToken, NOT_OK_PUNCTUATORS))
|
|
23
23
|
return [NOT_OK];
|
|
24
24
|
|
|
25
25
|
let curlyBracesBalance = 0;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
colon,
|
|
3
3
|
isIdentifier,
|
|
4
|
-
|
|
4
|
+
isOneOfIdentifiers,
|
|
5
5
|
isPunctuator,
|
|
6
6
|
openCurlyBrace,
|
|
7
7
|
} from '#types';
|
|
@@ -12,7 +12,7 @@ export const match = () => ({
|
|
|
12
12
|
'(__args) {': (vars, path) => {
|
|
13
13
|
const current = path.getPrev();
|
|
14
14
|
|
|
15
|
-
if (
|
|
15
|
+
if (isOneOfIdentifiers(current, ['if', 'function']))
|
|
16
16
|
return false;
|
|
17
17
|
|
|
18
18
|
if (isIdentifier(current))
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
assign,
|
|
3
3
|
isDeclarationKeyword,
|
|
4
4
|
isKeyword,
|
|
5
|
-
|
|
5
|
+
isPunctuator,
|
|
6
6
|
semicolon,
|
|
7
7
|
} from '#types';
|
|
8
8
|
|
|
@@ -18,13 +18,13 @@ export const match = () => ({
|
|
|
18
18
|
if (!isDeclarationKeyword(__x))
|
|
19
19
|
return false;
|
|
20
20
|
|
|
21
|
-
return !
|
|
21
|
+
return !isPunctuator(assign, __expr);
|
|
22
22
|
},
|
|
23
23
|
'__a.__b __expr': ({__expr}, path) => {
|
|
24
24
|
if (path.isNextPunctuator() && !path.isNextPunctuator(semicolon))
|
|
25
25
|
return false;
|
|
26
26
|
|
|
27
|
-
return !
|
|
27
|
+
return !isPunctuator(assign, __expr);
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
closeRoundBrace,
|
|
4
4
|
closeSquareBrace,
|
|
5
5
|
colon,
|
|
6
|
-
|
|
7
|
-
isOneOfPunctuators,
|
|
6
|
+
isOneOfIdentifiers,
|
|
8
7
|
isPunctuator,
|
|
9
8
|
openCurlyBrace,
|
|
10
9
|
openRoundBrace,
|
|
@@ -23,7 +22,7 @@ export const match = () => ({
|
|
|
23
22
|
return false;
|
|
24
23
|
|
|
25
24
|
for (const token of path.getAllPrev()) {
|
|
26
|
-
if (
|
|
25
|
+
if (isPunctuator(token, punctuators))
|
|
27
26
|
return false;
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -98,7 +97,7 @@ export const replace = () => ({
|
|
|
98
97
|
});
|
|
99
98
|
|
|
100
99
|
const check = ({__x}, path) => {
|
|
101
|
-
if (!
|
|
100
|
+
if (!isOneOfIdentifiers(__x, ['var', 'let', 'const']))
|
|
102
101
|
return false;
|
|
103
102
|
|
|
104
103
|
if (!path.isNext())
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
colon,
|
|
4
4
|
dot,
|
|
5
5
|
isKeyword,
|
|
6
|
-
|
|
6
|
+
isOneOfIdentifiers,
|
|
7
7
|
isPunctuator,
|
|
8
8
|
semicolon,
|
|
9
9
|
assign,
|
|
@@ -34,7 +34,7 @@ export const match = () => ({
|
|
|
34
34
|
if (isPunctuator(token, semicolon))
|
|
35
35
|
return false;
|
|
36
36
|
|
|
37
|
-
if (
|
|
37
|
+
if (isOneOfIdentifiers(token, keywords))
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -50,7 +50,7 @@ export const match = () => ({
|
|
|
50
50
|
return false;
|
|
51
51
|
|
|
52
52
|
for (const token of path.getAllPrev())
|
|
53
|
-
if (
|
|
53
|
+
if (isOneOfIdentifiers(token, keywords))
|
|
54
54
|
return false;
|
|
55
55
|
|
|
56
56
|
return true;
|
|
@@ -65,7 +65,7 @@ export const match = () => ({
|
|
|
65
65
|
const isNextCall = path.isNextCompare('__a.__b(');
|
|
66
66
|
|
|
67
67
|
for (const token of path.getAllPrev()) {
|
|
68
|
-
if (
|
|
68
|
+
if (isOneOfIdentifiers(token, keywords))
|
|
69
69
|
return false;
|
|
70
70
|
|
|
71
71
|
if (isPunctuator(token, [
|
package/lib/types/types.js
CHANGED
|
@@ -74,16 +74,7 @@ export const isDeclarationKeyword = (token, name) => {
|
|
|
74
74
|
return isIdentifier(token, name);
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
export const
|
|
78
|
-
for (const punctuator of punctuators) {
|
|
79
|
-
if (isPunctuator(token, punctuator))
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return false;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const isOneOfKeywords = (token, keywords) => {
|
|
77
|
+
export const isOneOfIdentifiers = (token, keywords) => {
|
|
87
78
|
for (const keyword of keywords) {
|
|
88
79
|
if (isIdentifier(token, keyword))
|
|
89
80
|
return true;
|
|
@@ -190,7 +181,7 @@ export const hasRoundBraces = (tokens) => {
|
|
|
190
181
|
const roundBraces = [openRoundBrace, closeRoundBrace];
|
|
191
182
|
|
|
192
183
|
for (const token of tokens) {
|
|
193
|
-
if (
|
|
184
|
+
if (isPunctuator(token, roundBraces))
|
|
194
185
|
return true;
|
|
195
186
|
}
|
|
196
187
|
|