@putout/plugin-for-of 8.0.0 → 8.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.
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {types} = require('putout');
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
isVariableDeclaration,
|
|
6
|
+
isIdentifier,
|
|
7
|
+
isArrayPattern,
|
|
8
|
+
isObjectPattern,
|
|
9
|
+
} = types;
|
|
5
10
|
|
|
6
11
|
module.exports.report = () => `Add missing declaration`;
|
|
7
12
|
|
|
@@ -12,7 +17,28 @@ module.exports.match = () => ({
|
|
|
12
17
|
|
|
13
18
|
const bindings = path.scope.getAllBindings();
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
if (isIdentifier(__a))
|
|
21
|
+
return !bindings[__a.name];
|
|
22
|
+
|
|
23
|
+
if (isArrayPattern(__a)) {
|
|
24
|
+
for (const element of __a.elements) {
|
|
25
|
+
if (!isIdentifier(element) || bindings[element.name])
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isObjectPattern(__a))
|
|
33
|
+
for (const property of __a.properties) {
|
|
34
|
+
if (property.computed)
|
|
35
|
+
return false;
|
|
36
|
+
|
|
37
|
+
if (!isIdentifier(property.key) || bindings[property.key.name])
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return true;
|
|
16
42
|
},
|
|
17
43
|
});
|
|
18
44
|
|
package/lib/for-each/index.js
CHANGED
|
@@ -7,8 +7,8 @@ const {
|
|
|
7
7
|
} = require('putout');
|
|
8
8
|
|
|
9
9
|
const {
|
|
10
|
-
ContinueStatement,
|
|
11
10
|
isIdentifier,
|
|
11
|
+
continueStatement,
|
|
12
12
|
} = types;
|
|
13
13
|
|
|
14
14
|
const {
|
|
@@ -138,9 +138,9 @@ function fixReturn(path) {
|
|
|
138
138
|
const {argument} = path.node;
|
|
139
139
|
|
|
140
140
|
if (!argument)
|
|
141
|
-
return replaceWith(path,
|
|
141
|
+
return replaceWith(path, continueStatement());
|
|
142
142
|
|
|
143
|
-
replaceWithMultiple(path, [argument,
|
|
143
|
+
replaceWithMultiple(path, [argument, continueStatement()]);
|
|
144
144
|
},
|
|
145
145
|
});
|
|
146
146
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-for-of",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin adds ability to apply for...of",
|
|
@@ -41,12 +41,11 @@
|
|
|
41
41
|
"@putout/plugin-remove-unused-variables": "*",
|
|
42
42
|
"@putout/plugin-remove-useless-arguments": "*",
|
|
43
43
|
"@putout/plugin-remove-useless-continue": "*",
|
|
44
|
-
"@putout/test": "^
|
|
44
|
+
"@putout/test": "^12.0.0",
|
|
45
45
|
"c8": "^10.0.0",
|
|
46
46
|
"eslint": "^9.0.0",
|
|
47
47
|
"eslint-plugin-n": "^17.0.0",
|
|
48
|
-
"eslint-plugin-putout": "^
|
|
49
|
-
"lerna": "^6.0.1",
|
|
48
|
+
"eslint-plugin-putout": "^25.0.1",
|
|
50
49
|
"madrun": "^10.0.0",
|
|
51
50
|
"montag": "^1.2.1",
|
|
52
51
|
"nodemon": "^3.0.1"
|