flatlint 1.34.0 → 1.35.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/add-missing-semicolon/index.js +10 -7
- package/lib/runner/path.js +11 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
semicolon,
|
|
5
5
|
arrow,
|
|
6
6
|
openCurlyBrace,
|
|
7
|
+
closeRoundBrace,
|
|
7
8
|
} from '#types';
|
|
8
9
|
|
|
9
10
|
export const report = () => 'Add missing semicolon';
|
|
@@ -27,13 +28,15 @@ export const match = () => ({
|
|
|
27
28
|
return true;
|
|
28
29
|
},
|
|
29
30
|
'__a(__args)': (vars, path) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const punctuators = [
|
|
32
|
+
comma,
|
|
33
|
+
semicolon,
|
|
34
|
+
arrow,
|
|
35
|
+
closeRoundBrace,
|
|
36
|
+
openCurlyBrace,
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
if (path.isNextPunctuator(punctuators))
|
|
37
40
|
return false;
|
|
38
41
|
|
|
39
42
|
if (path.isNextPunctuator(openCurlyBrace))
|
package/lib/runner/path.js
CHANGED
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
isWhiteSpace,
|
|
7
7
|
} from '#types';
|
|
8
8
|
|
|
9
|
+
const {isArray} = Array;
|
|
10
|
+
const maybeArray = (a) => isArray(a) ? a : [a];
|
|
11
|
+
|
|
9
12
|
export const createPath = ({tokens, start, end}) => ({
|
|
10
13
|
tokens,
|
|
11
14
|
start,
|
|
@@ -88,7 +91,7 @@ const createIsNextOperator = ({tokens, end}) => () => {
|
|
|
88
91
|
return isOperator(current);
|
|
89
92
|
};
|
|
90
93
|
|
|
91
|
-
const createIsNextPunctuator = ({tokens, end}) => (
|
|
94
|
+
const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
92
95
|
const current = next({
|
|
93
96
|
tokens,
|
|
94
97
|
end,
|
|
@@ -97,7 +100,12 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuator) => {
|
|
|
97
100
|
if (!current)
|
|
98
101
|
return false;
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
for (const punctuator of maybeArray(punctuators)) {
|
|
104
|
+
if (isPunctuator(current, punctuator))
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return false;
|
|
101
109
|
};
|
|
102
110
|
|
|
103
111
|
const createIsPrevIdentifier = ({tokens, start}) => (value) => {
|
|
@@ -127,3 +135,4 @@ const createGetAllNext = ({tokens, end}) => function*() {
|
|
|
127
135
|
yield current;
|
|
128
136
|
}
|
|
129
137
|
};
|
|
138
|
+
|