flatlint 1.44.0 → 1.45.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
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
closeRoundBrace,
|
|
2
3
|
colon,
|
|
3
4
|
isOneOfKeywords,
|
|
4
5
|
isPunctuator,
|
|
6
|
+
openRoundBrace,
|
|
5
7
|
quote,
|
|
6
8
|
} from '#types';
|
|
7
9
|
|
|
@@ -17,7 +19,12 @@ export const match = () => ({
|
|
|
17
19
|
},
|
|
18
20
|
'__x __a = __b,': check,
|
|
19
21
|
'__x __a,': check,
|
|
20
|
-
'return __expr,': ({}, path) =>
|
|
22
|
+
'return __expr,': ({__expr}, path) => {
|
|
23
|
+
if (isPunctuator(openRoundBrace, __expr) && !isPunctuator(closeRoundBrace, __expr))
|
|
24
|
+
return false;
|
|
25
|
+
|
|
26
|
+
return !path.isNextPunctuator(quote);
|
|
27
|
+
},
|
|
21
28
|
});
|
|
22
29
|
|
|
23
30
|
export const replace = () => ({
|
package/lib/runner/path.js
CHANGED
|
@@ -138,15 +138,7 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
|
|
|
138
138
|
if (!current)
|
|
139
139
|
return false;
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
return isPunctuator(current);
|
|
143
|
-
|
|
144
|
-
for (const punctuator of maybeArray(punctuators)) {
|
|
145
|
-
if (isPunctuator(current, punctuator))
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return false;
|
|
141
|
+
return isPunctuator(current, punctuators);
|
|
150
142
|
};
|
|
151
143
|
|
|
152
144
|
const createIsPrevPunctuator = ({tokens, start, end}) => (punctuators) => {
|
package/lib/types/types.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const {isArray} = Array;
|
|
2
|
+
const maybeArray = (a) => isArray(a) ? a : [a];
|
|
1
3
|
const isString = (a) => typeof a === 'string';
|
|
2
4
|
|
|
3
5
|
export const isTemplateTail = (a) => a?.type === 'TemplateTail';
|
|
@@ -55,9 +57,12 @@ export const isPunctuator = (token, punctuator) => {
|
|
|
55
57
|
if (!punctuator)
|
|
56
58
|
return true;
|
|
57
59
|
|
|
58
|
-
const
|
|
60
|
+
for (const {value} of maybeArray(punctuator)) {
|
|
61
|
+
if (token.value === value)
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
59
64
|
|
|
60
|
-
return
|
|
65
|
+
return false;
|
|
61
66
|
};
|
|
62
67
|
|
|
63
68
|
export const StringLiteral = (value) => ({
|