flatlint 5.2.1 → 5.3.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
|
@@ -228,6 +228,20 @@ if (a) {
|
|
|
228
228
|
|
|
229
229
|
</details>
|
|
230
230
|
|
|
231
|
+
<details><summary>remove useless import curly braces</summary>
|
|
232
|
+
|
|
233
|
+
```diff
|
|
234
|
+
-import info from '../package.json' {
|
|
235
|
+
- with: {
|
|
236
|
+
- type: 'json',
|
|
237
|
+
- }
|
|
238
|
+
+import info from '../package.json' with {
|
|
239
|
+
+ type: 'json',
|
|
240
|
+
-};
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
</details>
|
|
244
|
+
|
|
231
245
|
<details><summary>remove useless square brace</summary>
|
|
232
246
|
|
|
233
247
|
```diff
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
closeRoundBrace,
|
|
4
4
|
closeSquareBrace,
|
|
5
5
|
colon,
|
|
6
|
+
isBalancedRoundBraces,
|
|
6
7
|
isOneOfIdentifiers,
|
|
7
8
|
isPunctuator,
|
|
8
9
|
openCurlyBrace,
|
|
@@ -31,7 +32,19 @@ export const match = () => ({
|
|
|
31
32
|
|
|
32
33
|
return path.isNextKeyword();
|
|
33
34
|
},
|
|
34
|
-
'__x __a = __expr,':
|
|
35
|
+
'__x __a = __expr,': ({__expr}, path) => {
|
|
36
|
+
if (!isBalancedRoundBraces(__expr))
|
|
37
|
+
return false;
|
|
38
|
+
|
|
39
|
+
if (!path.isNext())
|
|
40
|
+
return true;
|
|
41
|
+
|
|
42
|
+
if (path.isNextIdentifier('module'))
|
|
43
|
+
return true;
|
|
44
|
+
|
|
45
|
+
if (path.isNextKeyword() && !path.isNextIdentifier('new'))
|
|
46
|
+
return true;
|
|
47
|
+
},
|
|
35
48
|
'__x __a,': check,
|
|
36
49
|
'return __expr,': ({__expr}, path) => {
|
|
37
50
|
if (isPunctuator(openRoundBrace, __expr) && !isPunctuator(closeRoundBrace, __expr))
|
|
@@ -105,11 +118,5 @@ const check = ({__x}, path) => {
|
|
|
105
118
|
if (!isOneOfIdentifiers(__x, ['var', 'let', 'const']))
|
|
106
119
|
return false;
|
|
107
120
|
|
|
108
|
-
if (!path.isNext())
|
|
109
|
-
return true;
|
|
110
|
-
|
|
111
|
-
if (path.isNextIdentifier('module'))
|
|
112
|
-
return true;
|
|
113
|
-
|
|
114
121
|
return path.isNextKeyword() && !path.isNextIdentifier('new');
|
|
115
122
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import montag from 'montag';
|
|
2
|
+
|
|
3
|
+
export const report = () => 'Remove useless curly braces from ImportDeclaration';
|
|
4
|
+
|
|
5
|
+
export const replace = () => ({
|
|
6
|
+
[montag`
|
|
7
|
+
import __a from "__b" {
|
|
8
|
+
with: {
|
|
9
|
+
type: 'json',
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
`]: montag`
|
|
13
|
+
import __a from "__b" with {
|
|
14
|
+
type: 'json',
|
|
15
|
+
};
|
|
16
|
+
`,
|
|
17
|
+
});
|
package/lib/plugins.js
CHANGED
|
@@ -17,6 +17,7 @@ import * as convertFromToRequire from './plugins/convert-from-to-require/index.j
|
|
|
17
17
|
import * as removeUselessComma from './plugins/remove-useless-comma/index.js';
|
|
18
18
|
import * as removeUselessArrow from './plugins/remove-useless-arrow/index.js';
|
|
19
19
|
import * as removeUselessDot from './plugins/remove-useless-dot/index.js';
|
|
20
|
+
import * as removeUselessImportCurlyBraces from './plugins/remove-useless-import-curly-braces/index.js';
|
|
20
21
|
import * as removeInvalidCharacter from './plugins/remove-invalid-character/index.js';
|
|
21
22
|
import * as removeUselessRoundBrace from './plugins/remove-useless-round-brace/index.js';
|
|
22
23
|
import * as splitNamespaceWithSpecifiers from './plugins/split-namespace-with-specifiers/index.js';
|
|
@@ -50,6 +51,7 @@ export const plugins = [
|
|
|
50
51
|
['convert-from-to-require', convertFromToRequire],
|
|
51
52
|
['remove-useless-comma', removeUselessComma],
|
|
52
53
|
['remove-useless-round-brace', removeUselessRoundBrace],
|
|
54
|
+
['remove-useless-import-curly-braces', removeUselessImportCurlyBraces],
|
|
53
55
|
['remove-useless-arrow', removeUselessArrow],
|
|
54
56
|
['remove-useless-assign', removeUselessAssign],
|
|
55
57
|
['remove-useless-dot', removeUselessDot],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flatlint",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "JavaScript tokens-based linter",
|
|
5
5
|
"main": "lib/flatlint.js",
|
|
6
6
|
"type": "module",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"@putout/engine-loader": "^17.0.4",
|
|
64
64
|
"@putout/operator-keyword": "^5.0.0",
|
|
65
65
|
"js-tokens": "^10.0.0",
|
|
66
|
+
"montag": "^1.2.1",
|
|
66
67
|
"obug": "^2.1.1"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
@@ -71,7 +72,6 @@
|
|
|
71
72
|
"eslint-plugin-putout": "^31.0.0",
|
|
72
73
|
"madrun": "^13.0.0",
|
|
73
74
|
"mock-require": "^3.0.3",
|
|
74
|
-
"montag": "^1.0.0",
|
|
75
75
|
"nodemon": "^3.0.1",
|
|
76
76
|
"putout": "^42.0.3",
|
|
77
77
|
"superc8": "^12.3.1",
|