flatlint 1.32.0 → 1.33.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 +5 -0
- package/lib/plugins/convert-comma-to-semicolon/index.js +15 -0
- package/lib/runner/path.js +16 -2
- package/lib/types/types.js +15 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -10,10 +10,25 @@ export const match = () => ({
|
|
|
10
10
|
|
|
11
11
|
return true;
|
|
12
12
|
},
|
|
13
|
+
'let __a = __b,': check,
|
|
14
|
+
'var __a = __b': check,
|
|
15
|
+
'let __a,': check,
|
|
16
|
+
'var __a,': check,
|
|
13
17
|
});
|
|
14
18
|
|
|
15
19
|
export const replace = () => ({
|
|
20
|
+
'var __a,': 'var __a;',
|
|
21
|
+
'let __a,': 'let __a;',
|
|
22
|
+
'var __a = __b,': 'var __a = __b;',
|
|
23
|
+
'let __a = __b,': 'let __a = __b;',
|
|
16
24
|
'const __a = __b,': 'const __a = __b;',
|
|
17
25
|
'__a(__args),': '__a(__args);',
|
|
18
26
|
'return __expr,': 'return __expr;',
|
|
19
27
|
});
|
|
28
|
+
|
|
29
|
+
const check = (vars, path) => {
|
|
30
|
+
if (!path.isNext())
|
|
31
|
+
return true;
|
|
32
|
+
|
|
33
|
+
return path.isNextOperator();
|
|
34
|
+
};
|
package/lib/runner/path.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isIdentifier,
|
|
3
3
|
isNewLine,
|
|
4
|
+
isOperator,
|
|
4
5
|
isPunctuator,
|
|
5
6
|
isWhiteSpace,
|
|
6
7
|
} from '#types';
|
|
@@ -21,6 +22,10 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
21
22
|
tokens,
|
|
22
23
|
end,
|
|
23
24
|
}),
|
|
25
|
+
isNextOperator: createIsNextOperator({
|
|
26
|
+
tokens,
|
|
27
|
+
end,
|
|
28
|
+
}),
|
|
24
29
|
isNextPunctuator: createIsNextPunctuator({
|
|
25
30
|
tokens,
|
|
26
31
|
end,
|
|
@@ -59,10 +64,10 @@ const next = ({tokens, end}) => {
|
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
const createIsNext = ({tokens, end}) => () => {
|
|
62
|
-
return next({
|
|
67
|
+
return Boolean(next({
|
|
63
68
|
tokens,
|
|
64
69
|
end,
|
|
65
|
-
});
|
|
70
|
+
}));
|
|
66
71
|
};
|
|
67
72
|
|
|
68
73
|
const createIsNextIdentifier = ({tokens, end}) => (value) => {
|
|
@@ -74,6 +79,15 @@ const createIsNextIdentifier = ({tokens, end}) => (value) => {
|
|
|
74
79
|
return isIdentifier(current, value);
|
|
75
80
|
};
|
|
76
81
|
|
|
82
|
+
const createIsNextOperator = ({tokens, end}) => () => {
|
|
83
|
+
const current = next({
|
|
84
|
+
tokens,
|
|
85
|
+
end,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return isOperator(current);
|
|
89
|
+
};
|
|
90
|
+
|
|
77
91
|
const createIsNextPunctuator = ({tokens, end}) => (punctuator) => {
|
|
78
92
|
const current = next({
|
|
79
93
|
tokens,
|
package/lib/types/types.js
CHANGED
|
@@ -15,6 +15,21 @@ export const isStringLiteral = ({type}) => type === 'StringLiteral';
|
|
|
15
15
|
export const isNumericLiteral = ({type}) => type === 'NumericLiteral';
|
|
16
16
|
export const isNewLine = ({type}) => type === 'LineTerminatorSequence';
|
|
17
17
|
export const notWhiteSpace = (a) => !isWhiteSpace(a);
|
|
18
|
+
export const isOperator = (token) => {
|
|
19
|
+
const operators = [
|
|
20
|
+
'var',
|
|
21
|
+
'let',
|
|
22
|
+
'const',
|
|
23
|
+
'export',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
for (const operator of operators) {
|
|
27
|
+
if (isIdentifier(token, operator))
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
18
33
|
export const isPunctuator = (token, punctuator) => {
|
|
19
34
|
if (token.type !== 'Punctuator')
|
|
20
35
|
return false;
|