flatlint 1.42.1 → 1.43.1
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 +9 -0
- package/lib/compare/compare.js +3 -0
- package/lib/plugins/add-missing-arrow/index.js +28 -0
- package/lib/plugins.js +4 -2
- package/lib/types/types.js +1 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -76,6 +76,15 @@ import {
|
|
|
76
76
|
|
|
77
77
|
</details>
|
|
78
78
|
|
|
79
|
+
<details><summary>add missing arrow <code>'=>'</code></summary>
|
|
80
|
+
|
|
81
|
+
```diff
|
|
82
|
+
-const a = (b, c) {};
|
|
83
|
+
+const a = (b, c) => {};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
</details>
|
|
87
|
+
|
|
79
88
|
<details><summary>add <code>const</code> to <code>export</code></summary>
|
|
80
89
|
|
|
81
90
|
```diff
|
package/lib/compare/compare.js
CHANGED
|
@@ -34,6 +34,9 @@ export const compare = (source, template, {index = 0} = {}) => {
|
|
|
34
34
|
for (let templateIndex = 0; templateIndex < templateTokensLength; templateIndex++) {
|
|
35
35
|
let currentTokenIndex = index + templateIndex - skip;
|
|
36
36
|
|
|
37
|
+
if (currentTokenIndex > n)
|
|
38
|
+
return [NOT_OK];
|
|
39
|
+
|
|
37
40
|
const templateToken = templateTokens[templateIndex];
|
|
38
41
|
const currentToken = tokens[currentTokenIndex];
|
|
39
42
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
colon,
|
|
3
|
+
isOneOfKeywords,
|
|
4
|
+
isPunctuator,
|
|
5
|
+
openCurlyBrace,
|
|
6
|
+
} from '#types';
|
|
7
|
+
|
|
8
|
+
export const report = () => `Add missing '=>'`;
|
|
9
|
+
|
|
10
|
+
export const match = () => ({
|
|
11
|
+
'(__args) {': (vars, path) => {
|
|
12
|
+
for (const current of path.getAllPrev()) {
|
|
13
|
+
if (isPunctuator(current, colon))
|
|
14
|
+
return true;
|
|
15
|
+
|
|
16
|
+
if (isPunctuator(current, openCurlyBrace))
|
|
17
|
+
return false;
|
|
18
|
+
|
|
19
|
+
if (isOneOfKeywords(current, ['if', 'function']))
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
export const replace = () => ({
|
|
27
|
+
'(__args) {': '(__args) => {',
|
|
28
|
+
});
|
package/lib/plugins.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as addMissingArrow from './plugins/add-missing-arrow/index.js';
|
|
2
2
|
import * as addMissingRoundBraces from './plugins/add-missing-round-braces/index.js';
|
|
3
3
|
import * as addMissingSquireBrace from './plugins/add-missing-square-brace/index.js';
|
|
4
4
|
import * as addMissingQuote from './plugins/add-missing-quote/index.js';
|
|
@@ -10,9 +10,10 @@ import * as convertFromToRequire from './plugins/convert-from-to-require/index.j
|
|
|
10
10
|
import * as removeUselessRoundBrace from './plugins/remove-useless-round-brace/index.js';
|
|
11
11
|
import * as removeUselessComma from './plugins/remove-useless-comma/index.js';
|
|
12
12
|
import * as removeInvalidCharacter from './plugins/remove-invalid-character/index.js';
|
|
13
|
+
import * as wrapAssignmentInParens from './plugins/wrap-assignment-in-parens/index.js';
|
|
13
14
|
|
|
14
15
|
export const plugins = [
|
|
15
|
-
['
|
|
16
|
+
['add-missing-arrow', addMissingArrow],
|
|
16
17
|
['add-missing-round-braces', addMissingRoundBraces],
|
|
17
18
|
['add-missing-squire-brace', addMissingSquireBrace],
|
|
18
19
|
['add-missing-semicolon', addMissingSemicolon],
|
|
@@ -24,4 +25,5 @@ export const plugins = [
|
|
|
24
25
|
['remove-useless-round-brace', removeUselessRoundBrace],
|
|
25
26
|
['remove-useless-comma', removeUselessComma],
|
|
26
27
|
['remove-invalid-character', removeInvalidCharacter],
|
|
28
|
+
['wrap-assignment-in-parens', wrapAssignmentInParens],
|
|
27
29
|
];
|
package/lib/types/types.js
CHANGED