flatlint 1.55.0 → 1.56.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,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
closeCurlyBrace,
|
|
2
3
|
closeRoundBrace,
|
|
3
4
|
isNewLine,
|
|
4
5
|
NOT_OK,
|
|
5
6
|
OK,
|
|
7
|
+
openCurlyBrace,
|
|
8
|
+
openRoundBrace,
|
|
6
9
|
} from '#types';
|
|
7
10
|
import {equal} from './equal.js';
|
|
8
11
|
|
|
@@ -13,16 +16,34 @@ export const collectArgs = ({currentTokenIndex, tokens}) => {
|
|
|
13
16
|
if (equal(tokens[index], closeRoundBrace))
|
|
14
17
|
return [NOT_OK];
|
|
15
18
|
|
|
19
|
+
let curlyBracesBalance = 0;
|
|
20
|
+
let roundBracesBalance = 0;
|
|
21
|
+
|
|
16
22
|
for (; index < n; index++) {
|
|
17
23
|
const token = tokens[index];
|
|
18
24
|
|
|
25
|
+
if (equal(token, openRoundBrace))
|
|
26
|
+
++roundBracesBalance;
|
|
27
|
+
|
|
19
28
|
if (equal(token, closeRoundBrace))
|
|
29
|
+
--roundBracesBalance;
|
|
30
|
+
|
|
31
|
+
if (equal(token, openCurlyBrace))
|
|
32
|
+
++curlyBracesBalance;
|
|
33
|
+
|
|
34
|
+
if (equal(token, closeCurlyBrace))
|
|
35
|
+
--curlyBracesBalance;
|
|
36
|
+
|
|
37
|
+
if (curlyBracesBalance < 0)
|
|
20
38
|
break;
|
|
21
39
|
|
|
22
|
-
if (
|
|
40
|
+
if (roundBracesBalance < 0)
|
|
23
41
|
break;
|
|
24
42
|
}
|
|
25
43
|
|
|
44
|
+
if (isNewLine(tokens[index - 1]))
|
|
45
|
+
--index;
|
|
46
|
+
|
|
26
47
|
return [
|
|
27
48
|
OK,
|
|
28
49
|
--index,
|
|
@@ -1,34 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
arrow,
|
|
3
|
+
closeCurlyBrace,
|
|
3
4
|
closeRoundBrace,
|
|
4
5
|
isPunctuator,
|
|
6
|
+
openCurlyBrace,
|
|
5
7
|
openRoundBrace,
|
|
6
8
|
} from '#types';
|
|
7
9
|
|
|
8
10
|
export const report = () => 'Add missing round brace';
|
|
9
11
|
|
|
10
12
|
export const match = () => ({
|
|
11
|
-
'(__args
|
|
12
|
-
if (!isPunctuator(openRoundBrace, __args))
|
|
13
|
-
return false;
|
|
14
|
-
|
|
15
|
-
return !isPunctuator(closeRoundBrace, __args);
|
|
16
|
-
},
|
|
17
|
-
'__a(__args': (vars, path) => {
|
|
13
|
+
'__a(__args': ({__args}, path) => {
|
|
18
14
|
if (path.isCurrentPunctuator(closeRoundBrace))
|
|
19
15
|
return false;
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
if (isPunctuator(token, closeRoundBrace))
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return true;
|
|
17
|
+
return !path.isNextPunctuator(closeRoundBrace);
|
|
27
18
|
},
|
|
28
19
|
});
|
|
29
20
|
|
|
30
21
|
export const replace = () => ({
|
|
31
22
|
'if __a > __b': 'if (__a > __b)',
|
|
32
23
|
'__a(__args': '__a(__args)',
|
|
33
|
-
'(__args) {': '(__args)) {',
|
|
24
|
+
'if (__a.__b(__args) {': 'if (__a.__b(__args)) {',
|
|
25
|
+
'if (__a(__args) {': 'if (__a(__args)) {',
|
|
34
26
|
});
|
|
27
|
+
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
export const report = () => 'Use semicolon instead of trailing comma';
|
|
13
13
|
export const match = () => ({
|
|
14
14
|
'__a(__args),': (vars, path) => {
|
|
15
|
+
if (path.isNextKeyword())
|
|
16
|
+
return true;
|
|
17
|
+
|
|
15
18
|
for (const token of path.getAllPrev()) {
|
|
16
19
|
if (isPunctuator(token, colon))
|
|
17
20
|
return false;
|
package/lib/runner/path.js
CHANGED
package/lib/types/types.js
CHANGED