flatlint 1.100.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 +5 -0
- package/README.md +4 -0
- package/lib/plugins/remove-useless-round-brace/index.js +20 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -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
|
+
|