flatlint 1.54.0 → 1.55.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/README.md +1 -1
- package/lib/plugins/add-missing-round-brace/index.js +0 -3
- package/lib/plugins/add-missing-semicolon/index.js +4 -1
- package/lib/plugins/{remove-useless-semicolon → convert-semicolon-to-comma}/index.js +1 -1
- package/lib/plugins.js +3 -1
- package/lib/runner/path.js +0 -39
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
export const report = () => 'Add missing semicolon';
|
|
14
14
|
|
|
15
15
|
export const match = () => ({
|
|
16
|
-
'const __a = __expr': (
|
|
16
|
+
'const __a = __expr': ({__expr}, path) => {
|
|
17
17
|
const punctuators = [
|
|
18
18
|
comma,
|
|
19
19
|
semicolon,
|
|
@@ -21,6 +21,9 @@ export const match = () => ({
|
|
|
21
21
|
question,
|
|
22
22
|
];
|
|
23
23
|
|
|
24
|
+
if (isPunctuator(openCurlyBrace, __expr))
|
|
25
|
+
return false;
|
|
26
|
+
|
|
24
27
|
if (path.isNextPunctuator(punctuators))
|
|
25
28
|
return false;
|
|
26
29
|
|
package/lib/plugins.js
CHANGED
|
@@ -8,9 +8,10 @@ import * as addMissingComma from './plugins/add-missing-comma/index.js';
|
|
|
8
8
|
import * as addConstToExport from './plugins/add-const-to-export/index.js';
|
|
9
9
|
import * as convertCommaToSemicolon from './plugins/convert-comma-to-semicolon/index.js';
|
|
10
10
|
import * as convertFromToRequire from './plugins/convert-from-to-require/index.js';
|
|
11
|
-
import * as removeUselessRoundBrace from './plugins/remove-useless-round-brace/index.js';
|
|
12
11
|
import * as removeUselessComma from './plugins/remove-useless-comma/index.js';
|
|
13
12
|
import * as removeInvalidCharacter from './plugins/remove-invalid-character/index.js';
|
|
13
|
+
import * as removeUselessRoundBrace from './plugins/remove-useless-round-brace/index.js';
|
|
14
|
+
import * as convertSemicolonToComma from './plugins/convert-semicolon-to-comma/index.js';
|
|
14
15
|
import * as wrapAssignmentInParens from './plugins/wrap-assignment-in-parens/index.js';
|
|
15
16
|
|
|
16
17
|
export const plugins = [
|
|
@@ -23,6 +24,7 @@ export const plugins = [
|
|
|
23
24
|
['add-missing-quote', addMissingQuote],
|
|
24
25
|
['add-const-to-export', addConstToExport],
|
|
25
26
|
['convert-comma-to-semicolon', convertCommaToSemicolon],
|
|
27
|
+
['convert-semicolon-to-comma', convertSemicolonToComma],
|
|
26
28
|
['convert-from-to-require', convertFromToRequire],
|
|
27
29
|
['remove-useless-round-brace', removeUselessRoundBrace],
|
|
28
30
|
['remove-useless-comma', removeUselessComma],
|
package/lib/runner/path.js
CHANGED
|
@@ -47,33 +47,12 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
47
47
|
tokens,
|
|
48
48
|
start,
|
|
49
49
|
}),
|
|
50
|
-
isPrevPunctuator: createIsPrevPunctuator({
|
|
51
|
-
tokens,
|
|
52
|
-
start,
|
|
53
|
-
end,
|
|
54
|
-
}),
|
|
55
50
|
isCurrentPunctuator: createIsNextPunctuator({
|
|
56
51
|
tokens,
|
|
57
52
|
end: end - 1,
|
|
58
53
|
}),
|
|
59
54
|
});
|
|
60
55
|
|
|
61
|
-
const prev = ({tokens, start, end}) => {
|
|
62
|
-
let i = end + 1;
|
|
63
|
-
|
|
64
|
-
while (--i >= start) {
|
|
65
|
-
const token = tokens[i];
|
|
66
|
-
|
|
67
|
-
if (isNewLine(token))
|
|
68
|
-
continue;
|
|
69
|
-
|
|
70
|
-
if (isWhiteSpace(token))
|
|
71
|
-
continue;
|
|
72
|
-
|
|
73
|
-
return token;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
56
|
const next = ({tokens, end}) => {
|
|
78
57
|
let i = end - 1;
|
|
79
58
|
|
|
@@ -145,24 +124,6 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
|
145
124
|
return isPunctuator(current, punctuators);
|
|
146
125
|
};
|
|
147
126
|
|
|
148
|
-
const createIsPrevPunctuator = ({tokens, start, end}) => (punctuators) => {
|
|
149
|
-
const current = prev({
|
|
150
|
-
tokens,
|
|
151
|
-
start,
|
|
152
|
-
end,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
if (!current)
|
|
156
|
-
return false;
|
|
157
|
-
|
|
158
|
-
for (const punctuator of maybeArray(punctuators)) {
|
|
159
|
-
if (isPunctuator(current, punctuator))
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return false;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
127
|
const createIsPrevIdentifier = ({tokens, start}) => (value) => {
|
|
167
128
|
const SPACE = 1;
|
|
168
129
|
const FUNCTION = 1;
|