flatlint 1.99.0 → 1.101.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 +13 -0
- package/lib/plugins/add-missing-round-brace/index.js +1 -3
- package/lib/plugins/remove-useless-comma/index.js +1 -1
- package/lib/plugins/remove-useless-dot/index.js +5 -0
- package/lib/plugins/remove-useless-round-brace/index.js +20 -0
- package/lib/plugins.js +2 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -155,6 +155,10 @@ t.transform('declare-imports-first', {
|
|
|
155
155
|
|
|
156
156
|
-import a from 'a');
|
|
157
157
|
+import a from 'a';
|
|
158
|
+
|
|
159
|
+
if (a) {
|
|
160
|
+
-})
|
|
161
|
+
+}
|
|
158
162
|
```
|
|
159
163
|
|
|
160
164
|
</details>
|
|
@@ -201,6 +205,15 @@ t.equal(expected, []);
|
|
|
201
205
|
|
|
202
206
|
</details>
|
|
203
207
|
|
|
208
|
+
<details><summary>remove useless dot</summary>
|
|
209
|
+
|
|
210
|
+
```diff
|
|
211
|
+
-fn([].);
|
|
212
|
+
+fn([].);
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
</details>
|
|
216
|
+
|
|
204
217
|
<details><summary>remove invalid character</summary>
|
|
205
218
|
|
|
206
219
|
```diff
|
|
@@ -23,9 +23,7 @@ export const match = () => ({
|
|
|
23
23
|
'if (__a(__args)': (vars, path) => {
|
|
24
24
|
return path.isNextKeyword();
|
|
25
25
|
},
|
|
26
|
-
'{__a} = __expr;': (vars, path) =>
|
|
27
|
-
return !path.isPrevDeclarationKeyword();
|
|
28
|
-
},
|
|
26
|
+
'{__a} = __expr;': (vars, path) => !path.isPrevDeclarationKeyword(),
|
|
29
27
|
'{__a} = __expr': (vars, path) => {
|
|
30
28
|
return path.isNextKeyword();
|
|
31
29
|
},
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
closeRoundBrace,
|
|
2
3
|
hasRoundBraces,
|
|
3
4
|
isBalancedRoundBraces,
|
|
5
|
+
isKeyword,
|
|
4
6
|
isPunctuator,
|
|
5
7
|
openRoundBrace,
|
|
6
8
|
} from '#types';
|
|
@@ -23,10 +25,28 @@ export const match = () => ({
|
|
|
23
25
|
|
|
24
26
|
return true;
|
|
25
27
|
},
|
|
28
|
+
'})': (vars, path) => {
|
|
29
|
+
let balance = 0;
|
|
30
|
+
|
|
31
|
+
for (const current of path.getAllPrev()) {
|
|
32
|
+
if (isPunctuator(current, openRoundBrace))
|
|
33
|
+
++balance;
|
|
34
|
+
|
|
35
|
+
if (isPunctuator(current, closeRoundBrace))
|
|
36
|
+
--balance;
|
|
37
|
+
|
|
38
|
+
if (isKeyword(current, 'if'))
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return !balance;
|
|
43
|
+
},
|
|
26
44
|
});
|
|
27
45
|
|
|
28
46
|
export const replace = () => ({
|
|
29
47
|
'const __a = __expr);': 'const __a = __expr;',
|
|
30
48
|
'from "__b")': 'from "__b"',
|
|
31
49
|
'__a);': '__a;',
|
|
50
|
+
'})': '}',
|
|
32
51
|
});
|
|
52
|
+
|
package/lib/plugins.js
CHANGED
|
@@ -10,6 +10,7 @@ import * as addConstToExport from './plugins/add-const-to-export/index.js';
|
|
|
10
10
|
import * as convertCommaToSemicolon from './plugins/convert-comma-to-semicolon/index.js';
|
|
11
11
|
import * as convertFromToRequire from './plugins/convert-from-to-require/index.js';
|
|
12
12
|
import * as removeUselessComma from './plugins/remove-useless-comma/index.js';
|
|
13
|
+
import * as removeUselessDot from './plugins/remove-useless-dot/index.js';
|
|
13
14
|
import * as removeInvalidCharacter from './plugins/remove-invalid-character/index.js';
|
|
14
15
|
import * as removeUselessRoundBrace from './plugins/remove-useless-round-brace/index.js';
|
|
15
16
|
import * as convertSemicolonToComma from './plugins/convert-semicolon-to-comma/index.js';
|
|
@@ -30,6 +31,7 @@ export const plugins = [
|
|
|
30
31
|
['convert-semicolon-to-comma', convertSemicolonToComma],
|
|
31
32
|
['convert-from-to-require', convertFromToRequire],
|
|
32
33
|
['remove-useless-round-brace', removeUselessRoundBrace],
|
|
34
|
+
['remove-useless-dot', removeUselessDot],
|
|
33
35
|
['remove-invalid-character', removeInvalidCharacter],
|
|
34
36
|
['wrap-assignment-in-parens', wrapAssignmentInParens],
|
|
35
37
|
];
|