flatlint 3.7.0 → 3.9.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
package/README.md
CHANGED
|
@@ -28,6 +28,15 @@ npm i flatlint
|
|
|
28
28
|
|
|
29
29
|
</details>
|
|
30
30
|
|
|
31
|
+
<details><summary>apply import <code>from</code></summary>
|
|
32
|
+
|
|
33
|
+
```diff
|
|
34
|
+
-import fs form 'node:fs';
|
|
35
|
+
+import fs from 'node:fs';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
</details>
|
|
39
|
+
|
|
31
40
|
<details><summary>assignment without parentheses after <code>&&</code></summary>
|
|
32
41
|
|
|
33
42
|
```diff
|
|
@@ -17,13 +17,13 @@ export const match = () => ({
|
|
|
17
17
|
if (isType && path.isNextCompare('__a ='))
|
|
18
18
|
return false;
|
|
19
19
|
|
|
20
|
-
if (
|
|
20
|
+
if (path.isPrevKeyword())
|
|
21
21
|
return false;
|
|
22
22
|
|
|
23
|
-
if (
|
|
23
|
+
if (!isType && isKeyword(__a))
|
|
24
24
|
return false;
|
|
25
25
|
|
|
26
|
-
if (
|
|
26
|
+
if (path.isNextKeyword())
|
|
27
27
|
return false;
|
|
28
28
|
|
|
29
29
|
if (path.isInsideTemplate())
|
|
@@ -59,4 +59,3 @@ export const replace = () => ({
|
|
|
59
59
|
'"__a"': '"__a",',
|
|
60
60
|
'}': '},',
|
|
61
61
|
});
|
|
62
|
-
|
|
@@ -24,19 +24,8 @@ export const match = () => ({
|
|
|
24
24
|
|
|
25
25
|
return true;
|
|
26
26
|
},
|
|
27
|
-
'})': (vars, path) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
for (const current of path.getAllPrev()) {
|
|
31
|
-
if (isPunctuator(current, openRoundBrace))
|
|
32
|
-
++balance;
|
|
33
|
-
|
|
34
|
-
if (isPunctuator(current, closeRoundBrace))
|
|
35
|
-
--balance;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return !balance;
|
|
39
|
-
},
|
|
27
|
+
'})': (vars, path) => isBracesBalanced(path),
|
|
28
|
+
')]': (vars, path) => !isBracesBalanced(path),
|
|
40
29
|
});
|
|
41
30
|
|
|
42
31
|
export const replace = () => ({
|
|
@@ -44,5 +33,20 @@ export const replace = () => ({
|
|
|
44
33
|
'from "__b")': 'from "__b"',
|
|
45
34
|
'__a);': '__a;',
|
|
46
35
|
'})': '}',
|
|
36
|
+
')]': ']',
|
|
47
37
|
'for (__a __b of __c))': 'for (__a __b of __c)',
|
|
48
38
|
});
|
|
39
|
+
|
|
40
|
+
function isBracesBalanced(path) {
|
|
41
|
+
let balance = 0;
|
|
42
|
+
|
|
43
|
+
for (const current of path.getAllPrev()) {
|
|
44
|
+
if (isPunctuator(current, openRoundBrace))
|
|
45
|
+
++balance;
|
|
46
|
+
|
|
47
|
+
if (isPunctuator(current, closeRoundBrace))
|
|
48
|
+
--balance;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return !balance;
|
|
52
|
+
}
|
package/lib/plugins.js
CHANGED
|
@@ -8,6 +8,7 @@ import * as addMissingSemicolon from './plugins/add-missing-semicolon/index.js';
|
|
|
8
8
|
import * as addMissingComma from './plugins/add-missing-comma/index.js';
|
|
9
9
|
import * as addConstToExport from './plugins/add-const-to-export/index.js';
|
|
10
10
|
import * as applyImportOrder from './plugins/apply-import-order/index.js';
|
|
11
|
+
import * as applyImportFrom from './plugins/apply-import-from/index.js';
|
|
11
12
|
import * as convertAssertToWith from './plugins/convert-assert-to-with/index.js';
|
|
12
13
|
import * as convertCommaToSemicolon from './plugins/convert-comma-to-semicolon/index.js';
|
|
13
14
|
import * as convertFromToRequire from './plugins/convert-from-to-require/index.js';
|
|
@@ -21,15 +22,16 @@ import * as convertColonToSemicolon from './plugins/convert-colon-to-semicolon/i
|
|
|
21
22
|
import * as wrapAssignmentInParens from './plugins/wrap-assignment-in-parens/index.js';
|
|
22
23
|
|
|
23
24
|
export const plugins = [
|
|
25
|
+
['add-missing-comma', addMissingComma],
|
|
26
|
+
['add-missing-quote', addMissingQuote],
|
|
27
|
+
['add-const-to-export', addConstToExport],
|
|
24
28
|
['add-missing-semicolon', addMissingSemicolon],
|
|
25
29
|
['add-missing-arrow', addMissingArrow],
|
|
26
30
|
['add-missing-assign', addMissingAssign],
|
|
27
31
|
['add-missing-curly-brace', addMissingCurlyBrace],
|
|
28
32
|
['add-missing-round-brace', addMissingRoundBrace],
|
|
29
33
|
['add-missing-squire-brace', addMissingSquireBrace],
|
|
30
|
-
['
|
|
31
|
-
['add-missing-quote', addMissingQuote],
|
|
32
|
-
['add-const-to-export', addConstToExport],
|
|
34
|
+
['apply-import-from', applyImportFrom],
|
|
33
35
|
['apply-import-order', applyImportOrder],
|
|
34
36
|
['convert-assert-to-with', convertAssertToWith],
|
|
35
37
|
['convert-comma-to-semicolon', convertCommaToSemicolon],
|