flatlint 1.24.1 → 1.25.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/README.md +4 -1
- package/lib/compare/compare.js +4 -1
- package/lib/plugins/add-missing-round-braces/index.js +7 -0
- package/lib/runner/path.js +0 -8
- package/lib/types/types.js +1 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -37,13 +37,16 @@ npm i flatlint
|
|
|
37
37
|
|
|
38
38
|
</details>
|
|
39
39
|
|
|
40
|
-
<details><summary>add missing round
|
|
40
|
+
<details><summary>add missing round brace</summary>
|
|
41
41
|
|
|
42
42
|
```diff
|
|
43
43
|
-if a > 5 {
|
|
44
44
|
+if (a > 5) {
|
|
45
45
|
alert();
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
-a('hello'
|
|
49
|
+
+a('hello');
|
|
47
50
|
```
|
|
48
51
|
|
|
49
52
|
</details>
|
package/lib/compare/compare.js
CHANGED
|
@@ -29,7 +29,8 @@ export const compare = (source, template) => {
|
|
|
29
29
|
|
|
30
30
|
for (let index = 0; index < n; index++) {
|
|
31
31
|
for (let templateIndex = 0; templateIndex < templateTokensLength; templateIndex++) {
|
|
32
|
-
|
|
32
|
+
let currentTokenIndex = index + templateIndex - skip;
|
|
33
|
+
|
|
33
34
|
const templateToken = templateTokens[templateIndex];
|
|
34
35
|
const currentToken = tokens[currentTokenIndex];
|
|
35
36
|
|
|
@@ -43,6 +44,8 @@ export const compare = (source, template) => {
|
|
|
43
44
|
|
|
44
45
|
if (!ok) {
|
|
45
46
|
++skip;
|
|
47
|
+
} else if (templateIndex === templateTokensLength - 1) {
|
|
48
|
+
currentTokenIndex = end;
|
|
46
49
|
} else {
|
|
47
50
|
delta = end - currentTokenIndex;
|
|
48
51
|
index = end - templateIndex;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import {closeRoundBrace} from '#types';
|
|
2
|
+
|
|
1
3
|
export const report = () => 'Add missing round braces';
|
|
2
4
|
|
|
5
|
+
export const match = () => ({
|
|
6
|
+
'__a(__args': (vars, path) => !path.isNextPunctuator(closeRoundBrace),
|
|
7
|
+
});
|
|
8
|
+
|
|
3
9
|
export const replace = () => ({
|
|
4
10
|
'if __a > __b': 'if (__a > __b)',
|
|
11
|
+
'__a(__args': '__a(__args)',
|
|
5
12
|
});
|
package/lib/runner/path.js
CHANGED
|
@@ -17,10 +17,6 @@ export const createPath = ({tokens, start, end}) => ({
|
|
|
17
17
|
tokens,
|
|
18
18
|
end,
|
|
19
19
|
}),
|
|
20
|
-
isNext: createIsNext({
|
|
21
|
-
tokens,
|
|
22
|
-
end,
|
|
23
|
-
}),
|
|
24
20
|
});
|
|
25
21
|
|
|
26
22
|
const createIsNextPunctuator = ({tokens, end}) => (punctuator) => {
|
|
@@ -37,10 +33,6 @@ const createIsEndsWithPunctuator = ({tokens, end}) => (punctuator) => {
|
|
|
37
33
|
return isPunctuator(current, punctuator);
|
|
38
34
|
};
|
|
39
35
|
|
|
40
|
-
const createIsNext = ({tokens, end}) => () => {
|
|
41
|
-
return Boolean(tokens[end]);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
36
|
const createGetAllPrev = ({tokens, start}) => function*() {
|
|
45
37
|
for (let i = start; i >= 0; --i) {
|
|
46
38
|
yield tokens[i];
|
package/lib/types/types.js
CHANGED