@putout/plugin-for-of 9.0.0 β 10.0.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/README.md +1 -1
- package/lib/for-each/index.js +16 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ npm i @putout/plugin-for-of
|
|
|
61
61
|
>
|
|
62
62
|
> (c) MDN
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
Checkout in π[**Putout Editor**](https://putout.vercel.app/#/gist/68d114f01384084cc3bec0a5d75f2dfa/0bb5201d36ed27f74728921aca95a04efa35c82d).
|
|
65
65
|
|
|
66
66
|
### β Example of incorrect code
|
|
67
67
|
|
package/lib/for-each/index.js
CHANGED
|
@@ -34,13 +34,16 @@ export const replace = () => ({
|
|
|
34
34
|
'__.forEach.call(__a, (__b) => __body)': 'for (const __b of __a) __body',
|
|
35
35
|
'__.forEach(__args)': (vars, path) => {
|
|
36
36
|
const {params, body} = path.node.arguments[0];
|
|
37
|
-
|
|
38
37
|
const item = getItem(params);
|
|
39
38
|
|
|
40
39
|
delete item.typeAnnotation;
|
|
41
40
|
|
|
42
41
|
const {length} = params;
|
|
43
42
|
|
|
43
|
+
for (const param of params) {
|
|
44
|
+
delete param.typeAnnotation;
|
|
45
|
+
}
|
|
46
|
+
|
|
44
47
|
const thisPassed = isIdentifier(params[0], {
|
|
45
48
|
name: 'this',
|
|
46
49
|
});
|
|
@@ -104,8 +107,7 @@ export const match = () => ({
|
|
|
104
107
|
if (path.node.arguments.length === 2 && !path.get('arguments.1').isThisExpression())
|
|
105
108
|
return false;
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
if (params.length >= 3 && params[0].isIdentifier({name: 'this'}))
|
|
110
|
+
if (isIndexWithThis(params))
|
|
109
111
|
return false;
|
|
110
112
|
|
|
111
113
|
const [paramPath] = params;
|
|
@@ -198,3 +200,14 @@ function isForBeforeFnUp(path) {
|
|
|
198
200
|
|
|
199
201
|
return true;
|
|
200
202
|
}
|
|
203
|
+
|
|
204
|
+
function isIndexWithThis(params) {
|
|
205
|
+
if (params.length < 3)
|
|
206
|
+
return false;
|
|
207
|
+
|
|
208
|
+
const [first] = params;
|
|
209
|
+
|
|
210
|
+
return first.isIdentifier({
|
|
211
|
+
name: 'this',
|
|
212
|
+
});
|
|
213
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-for-of",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "πPutout plugin adds ability to apply for...of",
|
|
@@ -41,17 +41,17 @@
|
|
|
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": "^14.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": "^
|
|
48
|
+
"eslint-plugin-putout": "^28.0.0",
|
|
49
49
|
"madrun": "^11.0.0",
|
|
50
50
|
"montag": "^1.2.1",
|
|
51
51
|
"nodemon": "^3.0.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"putout": ">=
|
|
54
|
+
"putout": ">=40"
|
|
55
55
|
},
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"engines": {
|