flatlint 1.76.0 → 1.78.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 +10 -0
- package/lib/plugins/convert-comma-to-semicolon/index.js +12 -11
- package/lib/runner/path.js +2 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
closeCurlyBrace,
|
|
2
3
|
closeRoundBrace,
|
|
3
4
|
closeSquareBrace,
|
|
4
5
|
colon,
|
|
@@ -14,20 +15,17 @@ import {
|
|
|
14
15
|
export const report = () => 'Use semicolon instead of trailing comma';
|
|
15
16
|
export const match = () => ({
|
|
16
17
|
'__a(__args),': (vars, path) => {
|
|
17
|
-
|
|
18
|
-
return true;
|
|
19
|
-
|
|
20
|
-
const punctuators = [
|
|
21
|
-
colon,
|
|
22
|
-
spread,
|
|
23
|
-
];
|
|
18
|
+
const punctuators = [colon, spread];
|
|
24
19
|
|
|
25
20
|
for (const token of path.getAllPrev()) {
|
|
26
21
|
if (isOneOfPunctuators(token, punctuators))
|
|
27
22
|
return false;
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
if (path.isNextPunctuator(closeCurlyBrace))
|
|
26
|
+
return true;
|
|
27
|
+
|
|
28
|
+
return path.isNextKeyword();
|
|
31
29
|
},
|
|
32
30
|
'__x __a = __expr,': check,
|
|
33
31
|
'__x __a,': check,
|
|
@@ -40,6 +38,9 @@ export const match = () => ({
|
|
|
40
38
|
|
|
41
39
|
return !path.isNextPunctuator(quote);
|
|
42
40
|
},
|
|
41
|
+
'__a.__b = __expr,': ({__expr}, path) => {
|
|
42
|
+
return !path.isNextPunctuator(quote);
|
|
43
|
+
},
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
export const replace = () => ({
|
|
@@ -49,10 +50,9 @@ export const replace = () => ({
|
|
|
49
50
|
'__a(__args),': '__a(__args);',
|
|
50
51
|
'return __expr,': 'return __expr;',
|
|
51
52
|
'__a.__b = __expr,': '__a.__b = __expr;',
|
|
52
|
-
'__a.__b.__c = __expr,': '__a.__b.__c = __expr;',
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
const check = ({__x}, path) => {
|
|
55
|
+
const check = ({__x, __a}, path) => {
|
|
56
56
|
if (!isOneOfKeywords(__x, ['var', 'let', 'const']))
|
|
57
57
|
return false;
|
|
58
58
|
|
|
@@ -62,5 +62,6 @@ const check = ({__x}, path) => {
|
|
|
62
62
|
if (path.isNextIdentifier('module'))
|
|
63
63
|
return true;
|
|
64
64
|
|
|
65
|
-
return path.isNextKeyword();
|
|
65
|
+
return path.isNextKeyword() && !path.isNextIdentifier('new');
|
|
66
66
|
};
|
|
67
|
+
|
package/lib/runner/path.js
CHANGED
|
@@ -97,13 +97,13 @@ const createIsInsideTemplate = ({tokens, end}) => () => {
|
|
|
97
97
|
return isTemplateMiddle(current);
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
const createIsNextKeyword = ({tokens, end}) => () => {
|
|
100
|
+
const createIsNextKeyword = ({tokens, end}) => (name) => {
|
|
101
101
|
const current = next({
|
|
102
102
|
tokens,
|
|
103
103
|
end,
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
return isKeyword(current);
|
|
106
|
+
return isKeyword(current, name);
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|