flatlint 1.64.0 → 1.66.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 +13 -0
- package/lib/compare/collect-args.js +1 -4
- package/lib/compare/compare.js +3 -4
- package/lib/plugins/add-missing-semicolon/index.js +10 -11
- package/lib/runner/path.js +0 -10
- package/lib/runner/replacer.js +5 -3
- package/lib/types/types.js +14 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -11,10 +11,7 @@ import {
|
|
|
11
11
|
} from '#types';
|
|
12
12
|
import {equal} from './equal.js';
|
|
13
13
|
|
|
14
|
-
const NOT_OK_PUNCTUATORS = [
|
|
15
|
-
semicolon,
|
|
16
|
-
closeRoundBrace,
|
|
17
|
-
];
|
|
14
|
+
const NOT_OK_PUNCTUATORS = [semicolon, closeRoundBrace];
|
|
18
15
|
|
|
19
16
|
export const collectArgs = ({currentTokenIndex, tokens}) => {
|
|
20
17
|
let index = currentTokenIndex;
|
package/lib/compare/compare.js
CHANGED
|
@@ -64,11 +64,10 @@ export const compare = (source, template, {index = 0} = {}) => {
|
|
|
64
64
|
nextTemplateToken: templateTokens[templateIndex + 1],
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
if (indexOfExpressionEnd >= n - 1)
|
|
67
|
+
if (indexOfExpressionEnd >= n - 1) {
|
|
68
68
|
end = indexOfExpressionEnd;
|
|
69
|
-
|
|
70
|
-
if (templateIndex === templateTokensLength - 1) {
|
|
71
|
-
//delta = index;
|
|
69
|
+
currentTokenIndex = end;
|
|
70
|
+
} else if (templateIndex === templateTokensLength - 1) {
|
|
72
71
|
currentTokenIndex = end;
|
|
73
72
|
} else {
|
|
74
73
|
delta = indexOfExpressionEnd - currentTokenIndex;
|
|
@@ -7,12 +7,19 @@ import {
|
|
|
7
7
|
closeRoundBrace,
|
|
8
8
|
question,
|
|
9
9
|
closeCurlyBrace,
|
|
10
|
+
isOnlyWhitespaces,
|
|
10
11
|
} from '#types';
|
|
11
12
|
|
|
12
13
|
export const report = () => 'Add missing semicolon';
|
|
13
14
|
|
|
14
15
|
export const match = () => ({
|
|
15
|
-
'const __a = __expr': (
|
|
16
|
+
'const __a = __expr': ({__expr}, path) => {
|
|
17
|
+
if (isOnlyWhitespaces(__expr))
|
|
18
|
+
return false;
|
|
19
|
+
|
|
20
|
+
if (!path.isNext())
|
|
21
|
+
return true;
|
|
22
|
+
|
|
16
23
|
const punctuators = [
|
|
17
24
|
comma,
|
|
18
25
|
semicolon,
|
|
@@ -20,16 +27,7 @@ export const match = () => ({
|
|
|
20
27
|
question,
|
|
21
28
|
];
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
return true;
|
|
25
|
-
|
|
26
|
-
if (path.isNextPunctuator(punctuators))
|
|
27
|
-
return false;
|
|
28
|
-
|
|
29
|
-
for (const token of path.getAllNext()) {
|
|
30
|
-
if (isPunctuator(token, semicolon))
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
30
|
+
return !path.isNextPunctuator(punctuators);
|
|
33
31
|
},
|
|
34
32
|
'__a(__args)': (vars, path) => {
|
|
35
33
|
if (path.isNextPunctuator() && !path.isNextPunctuator(closeCurlyBrace))
|
|
@@ -56,3 +54,4 @@ export const replace = () => ({
|
|
|
56
54
|
|
|
57
55
|
'})': '});',
|
|
58
56
|
});
|
|
57
|
+
|
package/lib/runner/path.js
CHANGED
|
@@ -20,10 +20,6 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
20
20
|
tokens,
|
|
21
21
|
start,
|
|
22
22
|
}),
|
|
23
|
-
getAllNext: createGetAllNext({
|
|
24
|
-
tokens,
|
|
25
|
-
end,
|
|
26
|
-
}),
|
|
27
23
|
isNextKeyword: createIsNextKeyword({
|
|
28
24
|
tokens,
|
|
29
25
|
end,
|
|
@@ -134,9 +130,3 @@ const createGetAllPrev = ({tokens, start}) => function*() {
|
|
|
134
130
|
yield tokens[i];
|
|
135
131
|
}
|
|
136
132
|
};
|
|
137
|
-
|
|
138
|
-
const createGetAllNext = ({tokens, end}) => function*() {
|
|
139
|
-
for (let i = end; i < tokens.length; ++i) {
|
|
140
|
-
yield tokens[i];
|
|
141
|
-
}
|
|
142
|
-
};
|
package/lib/runner/replacer.js
CHANGED
|
@@ -70,14 +70,16 @@ export const replace = (tokens, {fix, rule, plugin}) => {
|
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const {line, column} = tokens[
|
|
73
|
+
const {line, column} = tokens[end - 1];
|
|
74
74
|
const message = plugin.report();
|
|
75
75
|
|
|
76
76
|
places.push({
|
|
77
77
|
rule,
|
|
78
78
|
message,
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
position: {
|
|
80
|
+
line,
|
|
81
|
+
column,
|
|
82
|
+
},
|
|
81
83
|
});
|
|
82
84
|
|
|
83
85
|
index = end;
|
package/lib/types/types.js
CHANGED
|
@@ -155,3 +155,17 @@ export const quote = Punctuator(`'`);
|
|
|
155
155
|
|
|
156
156
|
export const OK = true;
|
|
157
157
|
export const NOT_OK = false;
|
|
158
|
+
|
|
159
|
+
export const isOnlyWhitespaces = (tokens) => {
|
|
160
|
+
for (const token of tokens) {
|
|
161
|
+
if (isWhiteSpace(token))
|
|
162
|
+
continue;
|
|
163
|
+
|
|
164
|
+
if (isNewLine(token))
|
|
165
|
+
continue;
|
|
166
|
+
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return true;
|
|
171
|
+
};
|