@putout/plugin-putout 22.14.0 → 23.0.1
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.
|
@@ -23,6 +23,7 @@ module.exports.match = () => ({
|
|
|
23
23
|
't.noReport(__a)': check,
|
|
24
24
|
't.report(__a, __b)': check,
|
|
25
25
|
't.transform(__a)': check,
|
|
26
|
+
't.transform(__a, __b)': check,
|
|
26
27
|
't.noTransform(__a)': check,
|
|
27
28
|
});
|
|
28
29
|
|
|
@@ -30,6 +31,7 @@ module.exports.replace = () => ({
|
|
|
30
31
|
't.noReport(__a)': transform,
|
|
31
32
|
't.report(__a, __b)': transform,
|
|
32
33
|
't.transform(__a)': transform,
|
|
34
|
+
't.transform(__a, __b)': transform,
|
|
33
35
|
't.noTransform(__a)': transform,
|
|
34
36
|
});
|
|
35
37
|
|
|
@@ -29,7 +29,10 @@ module.exports.traverse = ({push}) => ({
|
|
|
29
29
|
if (!statement)
|
|
30
30
|
return;
|
|
31
31
|
|
|
32
|
-
const forOfCount = statement.parentPath
|
|
32
|
+
const forOfCount = statement.parentPath
|
|
33
|
+
.get('body')
|
|
34
|
+
.filter(isForOfStatement)
|
|
35
|
+
.length;
|
|
33
36
|
|
|
34
37
|
if (forOfCount > 1)
|
|
35
38
|
return;
|
|
@@ -15,10 +15,6 @@ const {
|
|
|
15
15
|
insertBefore,
|
|
16
16
|
} = operator;
|
|
17
17
|
|
|
18
|
-
const isRecast = (program) => program.get('body.0.expression').isStringLiteral({
|
|
19
|
-
value: 'use strict',
|
|
20
|
-
});
|
|
21
|
-
|
|
22
18
|
module.exports.report = () => {
|
|
23
19
|
return `Use 'operator.replaceWith()' instead of 'path.replaceWith()'`;
|
|
24
20
|
};
|
|
@@ -41,9 +37,7 @@ module.exports.fix = ({path, calleePath, property, object, program, isInserted})
|
|
|
41
37
|
const first = program.get('body.0');
|
|
42
38
|
const pathToInsert = types ? types.path.parentPath : first;
|
|
43
39
|
|
|
44
|
-
if (
|
|
45
|
-
insertAfter(pathToInsert, replaceWithAST);
|
|
46
|
-
else if (types)
|
|
40
|
+
if (types)
|
|
47
41
|
insertAfter(pathToInsert, replaceWithAST);
|
|
48
42
|
else
|
|
49
43
|
insertBefore(pathToInsert, replaceWithAST);
|
|
@@ -6,19 +6,10 @@ const {
|
|
|
6
6
|
types,
|
|
7
7
|
} = require('putout');
|
|
8
8
|
|
|
9
|
-
const {
|
|
10
|
-
insertAfter,
|
|
11
|
-
replaceWith,
|
|
12
|
-
insertBefore,
|
|
13
|
-
} = operator;
|
|
9
|
+
const {replaceWith, insertBefore} = operator;
|
|
14
10
|
|
|
15
11
|
const {Identifier, ObjectProperty} = types;
|
|
16
12
|
|
|
17
|
-
const isRecast = (program) => program.get('body.0').get('expression')
|
|
18
|
-
.isStringLiteral({
|
|
19
|
-
value: 'use strict',
|
|
20
|
-
});
|
|
21
|
-
|
|
22
13
|
module.exports.report = () => {
|
|
23
14
|
return `"operate.replaceWithMultiple" should be called instead of "path.replaceWithMultiple"`;
|
|
24
15
|
};
|
|
@@ -37,12 +28,8 @@ module.exports.fix = ({path, calleePath, property, object, program}) => {
|
|
|
37
28
|
if (bindings.replaceWithMultiple)
|
|
38
29
|
return;
|
|
39
30
|
|
|
40
|
-
if (!bindings.replaceWith && !bindings.insertAfter)
|
|
41
|
-
if (isRecast(program))
|
|
42
|
-
return insertAfter(first, replaceWithAST);
|
|
43
|
-
|
|
31
|
+
if (!bindings.replaceWith && !bindings.insertAfter)
|
|
44
32
|
return insertBefore(first, replaceWithAST);
|
|
45
|
-
}
|
|
46
33
|
|
|
47
34
|
const id = Identifier('replaceWithMultiple');
|
|
48
35
|
const varPath = getVarPath(bindings);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.0.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin helps with plugins development",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"chalk": "^5.3.0",
|
|
50
50
|
"eslint": "^9.0.0",
|
|
51
51
|
"eslint-plugin-n": "^17.0.0",
|
|
52
|
-
"eslint-plugin-putout": "^
|
|
52
|
+
"eslint-plugin-putout": "^24.0.0",
|
|
53
53
|
"lerna": "^6.0.1",
|
|
54
54
|
"madrun": "^10.0.0",
|
|
55
55
|
"montag": "^1.2.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"supertape": "^10.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"putout": ">=
|
|
60
|
+
"putout": ">=38"
|
|
61
61
|
},
|
|
62
62
|
"license": "MIT",
|
|
63
63
|
"engines": {
|