@putout/plugin-putout 9.0.0 → 10.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.
- package/README.md +1 -1
- package/lib/check-replace-code/index.js +14 -0
- package/lib/convert-add-argument-to-add-args/index.js +0 -2
- package/lib/convert-replace-with/index.js +0 -1
- package/lib/convert-replace-with-multiple/index.js +24 -36
- package/lib/declare/operator.js +2 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-putout.svg?style=flat&longCache=true
|
|
4
4
|
[NPMURL]: https://npmjs.org/package/@putout/plugin-putout"npm"
|
|
5
5
|
|
|
6
|
-
🐊[`Putout`](https://github.com/coderaiser/putout) plugin helps with
|
|
6
|
+
🐊[`Putout`](https://github.com/coderaiser/putout) plugin helps with plugins development.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -44,6 +44,9 @@ module.exports.traverse = ({push}) => ({
|
|
|
44
44
|
if (get(path))
|
|
45
45
|
return;
|
|
46
46
|
|
|
47
|
+
if (hasMatch(path))
|
|
48
|
+
return;
|
|
49
|
+
|
|
47
50
|
for (const propertyPath of path.get('right.body.properties')) {
|
|
48
51
|
if (!propertyPath.get('value').isStringLiteral())
|
|
49
52
|
continue;
|
|
@@ -117,3 +120,14 @@ function parseKey(propertyPath) {
|
|
|
117
120
|
return [null, key];
|
|
118
121
|
}
|
|
119
122
|
|
|
123
|
+
function hasMatch(path) {
|
|
124
|
+
const {body} = path.scope.getProgramParent().path.node;
|
|
125
|
+
|
|
126
|
+
for (const current of body) {
|
|
127
|
+
if (compare(current, 'module.exports.match = __a'))
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const fullstore = require('fullstore');
|
|
4
|
-
|
|
5
3
|
const {
|
|
6
4
|
operator,
|
|
7
5
|
template,
|
|
@@ -26,7 +24,7 @@ const replaceWithAST = template.ast(`
|
|
|
26
24
|
const {replaceWithMultiple} = require('putout').operate;
|
|
27
25
|
`);
|
|
28
26
|
|
|
29
|
-
module.exports.fix = ({path, calleePath, property, object, program
|
|
27
|
+
module.exports.fix = ({path, calleePath, property, object, program}) => {
|
|
30
28
|
const strictModePath = program.get('body.0');
|
|
31
29
|
const {bindings} = strictModePath.scope;
|
|
32
30
|
|
|
@@ -36,11 +34,6 @@ module.exports.fix = ({path, calleePath, property, object, program, isInserted})
|
|
|
36
34
|
if (bindings.replaceWithMultiple)
|
|
37
35
|
return;
|
|
38
36
|
|
|
39
|
-
if (isInserted())
|
|
40
|
-
return;
|
|
41
|
-
|
|
42
|
-
isInserted(true);
|
|
43
|
-
|
|
44
37
|
if (!bindings.replaceWith && !bindings.insertAfter)
|
|
45
38
|
return insertAfter(strictModePath, replaceWithAST);
|
|
46
39
|
|
|
@@ -63,32 +56,27 @@ function getVarPath(bindings) {
|
|
|
63
56
|
return insertAfter.path;
|
|
64
57
|
}
|
|
65
58
|
|
|
66
|
-
module.exports.traverse = ({push}) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
property,
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
};
|
|
59
|
+
module.exports.traverse = ({push}) => ({
|
|
60
|
+
CallExpression(path) {
|
|
61
|
+
const calleePath = path.get('callee');
|
|
62
|
+
|
|
63
|
+
if (!calleePath.isMemberExpression())
|
|
64
|
+
return;
|
|
65
|
+
|
|
66
|
+
const {object, property} = calleePath.node;
|
|
67
|
+
|
|
68
|
+
if (property.name !== 'replaceWithMultiple')
|
|
69
|
+
return;
|
|
70
|
+
|
|
71
|
+
const program = path.findParent((path) => path.isProgram());
|
|
72
|
+
|
|
73
|
+
push({
|
|
74
|
+
path,
|
|
75
|
+
object,
|
|
76
|
+
program,
|
|
77
|
+
calleePath,
|
|
78
|
+
property,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
});
|
|
94
82
|
|
package/lib/declare/operator.js
CHANGED
|
@@ -13,7 +13,8 @@ module.exports = {
|
|
|
13
13
|
addArgument: `const {addArgument} = operator`,
|
|
14
14
|
replaceWith: `const {replaceWith} = operator`,
|
|
15
15
|
replaceWithMultiple: `const {replaceWithMultiple} = operator`,
|
|
16
|
-
getProperties: `const {getProperties} = operator`,
|
|
17
16
|
isESM: `const {isESM} = operator`,
|
|
17
|
+
getProperty: `const {getProperty} = operator`,
|
|
18
|
+
getProperties: `const {getProperties} = operator`,
|
|
18
19
|
};
|
|
19
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.1.0",
|
|
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",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"c8": "^7.5.0",
|
|
41
41
|
"eslint": "^8.0.1",
|
|
42
42
|
"eslint-plugin-node": "^11.0.0",
|
|
43
|
-
"eslint-plugin-putout": "^
|
|
43
|
+
"eslint-plugin-putout": "^13.0.0",
|
|
44
44
|
"lerna": "^4.0.0",
|
|
45
45
|
"madrun": "^8.0.1",
|
|
46
46
|
"montag": "^1.2.1",
|
|
47
47
|
"nodemon": "^2.0.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"putout": ">=24"
|
|
50
|
+
"putout": ">=24.2"
|
|
51
51
|
},
|
|
52
52
|
"license": "MIT",
|
|
53
53
|
"engines": {
|