@putout/plugin-for-of 12.0.0 → 12.1.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.
|
@@ -6,12 +6,6 @@ const {replaceWith} = operator;
|
|
|
6
6
|
export const report = () => `Avoid useless for-of`;
|
|
7
7
|
|
|
8
8
|
export const match = () => ({
|
|
9
|
-
'for (const __identifier__a of __identifier__b) __c': ({__identifier__a}, path) => {
|
|
10
|
-
const {name} = __identifier__a;
|
|
11
|
-
const {references} = path.scope.bindings[name];
|
|
12
|
-
|
|
13
|
-
return !references;
|
|
14
|
-
},
|
|
15
9
|
'for (const __a of __array) __c': ({__a, __array}, path) => {
|
|
16
10
|
if (__array.elements.length >= 2)
|
|
17
11
|
return false;
|
|
@@ -24,10 +18,15 @@ export const match = () => ({
|
|
|
24
18
|
|
|
25
19
|
return !(references >= 2);
|
|
26
20
|
},
|
|
21
|
+
'for (const __identifier__a of __b) __c': ({__identifier__a}, path) => {
|
|
22
|
+
const {name} = __identifier__a;
|
|
23
|
+
const {references} = path.scope.bindings[name];
|
|
24
|
+
|
|
25
|
+
return !references;
|
|
26
|
+
},
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
export const replace = () => ({
|
|
30
|
-
'for (const __identifier__a of __identifier__b) __c': '__c',
|
|
31
30
|
'for (const __a of __array) __c': ({__a, __c, __array}, path) => {
|
|
32
31
|
const {elements} = __array;
|
|
33
32
|
|
|
@@ -49,4 +48,5 @@ export const replace = () => ({
|
|
|
49
48
|
|
|
50
49
|
return path;
|
|
51
50
|
},
|
|
51
|
+
'for (const __identifier__a of __b) __c': '__c',
|
|
52
52
|
});
|
package/package.json
CHANGED