@putout/plugin-for-of 2.0.0 → 4.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 +2 -3
- package/lib/for-each/index.js +4 -1
- package/lib/index.js +26 -16
- package/lib/remove-unused-variables/index.js +1 -2
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -67,9 +67,8 @@ for (const name of names) {
|
|
|
67
67
|
|
|
68
68
|
```js
|
|
69
69
|
for (const item in object) {
|
|
70
|
-
if (object.hasOwnProperty(item))
|
|
70
|
+
if (object.hasOwnProperty(item))
|
|
71
71
|
log(item);
|
|
72
|
-
}
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
for (const item in object) {
|
|
@@ -289,7 +288,7 @@ for (const [i, item] of array.entries()) {
|
|
|
289
288
|
|
|
290
289
|
### for-entries-n
|
|
291
290
|
|
|
292
|
-
|
|
291
|
+
#### ❌ Example of incorrect code
|
|
293
292
|
|
|
294
293
|
```js
|
|
295
294
|
const n = array.length;
|
package/lib/for-each/index.js
CHANGED
|
@@ -30,7 +30,7 @@ const forOfEntriesTemplate = template(`
|
|
|
30
30
|
const {keys} = Object;
|
|
31
31
|
const isRoot = (path) => path.isFunction() || path.isProgram();
|
|
32
32
|
|
|
33
|
-
module.exports.report = () => `for-of
|
|
33
|
+
module.exports.report = () => `Use 'for-of' instead of 'forEach()'`;
|
|
34
34
|
|
|
35
35
|
module.exports.replace = () => ({
|
|
36
36
|
'__.forEach.call(__a, (__b) => __body)': 'for (const __b of __a) __body',
|
|
@@ -78,6 +78,9 @@ module.exports.replace = () => ({
|
|
|
78
78
|
|
|
79
79
|
module.exports.match = () => ({
|
|
80
80
|
'__.forEach(__args)': (vars, path) => {
|
|
81
|
+
if (path.parentPath.isSequenceExpression())
|
|
82
|
+
return false;
|
|
83
|
+
|
|
81
84
|
const objectPath = path.get('callee.object');
|
|
82
85
|
const fnPath = path.get('arguments.0');
|
|
83
86
|
|
package/lib/index.js
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const map = require('./map');
|
|
4
|
+
const forEach = require('./for-each');
|
|
5
|
+
const forN = require('./for-n');
|
|
6
|
+
const forLength = require('./for-length');
|
|
7
|
+
const forEntries = require('./for-entries');
|
|
8
|
+
const forEntriesN = require('./for-entries-n');
|
|
9
|
+
const forInNegative = require('./for-in-negative');
|
|
10
|
+
const forInPositive = require('./for-in-positive');
|
|
11
|
+
const reduce = require('./reduce');
|
|
12
|
+
const removeUseless = require('./remove-useless');
|
|
13
|
+
const removeUselessVariables = require('./remove-useless-variables');
|
|
14
|
+
const removeUselessArrayFrom = require('./remove-useless-array-from');
|
|
15
|
+
const removeUnusedVariables = require('./remove-unused-variables');
|
|
6
16
|
|
|
7
17
|
module.exports.rules = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
map,
|
|
19
|
+
'for-each': forEach,
|
|
20
|
+
'for-n': forN,
|
|
21
|
+
'for-length': forLength,
|
|
22
|
+
'for-entries': forEntries,
|
|
23
|
+
'for-entries-n': forEntriesN,
|
|
24
|
+
'for-in-negative': forInNegative,
|
|
25
|
+
'for-in-positive': forInPositive,
|
|
26
|
+
reduce,
|
|
27
|
+
'remove-useless': removeUseless,
|
|
28
|
+
'remove-useless-variables': removeUselessVariables,
|
|
29
|
+
'remove-useless-array-from': removeUselessArrayFrom,
|
|
30
|
+
'remove-unused-variables': removeUnusedVariables,
|
|
21
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-for-of",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.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",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"@putout/plugin-remove-unused-variables": "*",
|
|
41
41
|
"@putout/plugin-remove-useless-arguments": "*",
|
|
42
42
|
"@putout/plugin-remove-useless-continue": "*",
|
|
43
|
-
"@putout/test": "^
|
|
44
|
-
"c8": "^
|
|
45
|
-
"eslint": "^
|
|
43
|
+
"@putout/test": "^8.0.0",
|
|
44
|
+
"c8": "^9.0.0",
|
|
45
|
+
"eslint": "^9.0.0-alpha.0",
|
|
46
46
|
"eslint-plugin-n": "^16.0.0",
|
|
47
|
-
"eslint-plugin-putout": "^
|
|
47
|
+
"eslint-plugin-putout": "^22.0.0",
|
|
48
48
|
"lerna": "^6.0.1",
|
|
49
|
-
"madrun": "^
|
|
49
|
+
"madrun": "^10.0.0",
|
|
50
50
|
"montag": "^1.2.1",
|
|
51
|
-
"nodemon": "^
|
|
51
|
+
"nodemon": "^3.0.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"putout": ">=
|
|
54
|
+
"putout": ">=34"
|
|
55
55
|
},
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
58
|
+
"node": ">=18"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|