@putout/plugin-putout 12.2.0 → 12.3.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 -2
- package/lib/check-replace-code/generate-code.js +1 -4
- package/lib/check-replace-code/index.js +2 -6
- package/lib/convert-babel-types/index.js +5 -2
- package/lib/convert-find-to-traverse/index.js +1 -3
- package/lib/convert-replace-with/index.js +1 -0
- package/lib/convert-replace-with-multiple/index.js +1 -0
- package/lib/convert-traverse-to-include/index.js +2 -1
- package/lib/convert-traverse-to-replace/index.js +2 -6
- package/lib/move-require-on-top-level/index.js +2 -4
- package/lib/replace-test-message/index.js +2 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -119,15 +119,11 @@ function parseKey(propertyPath) {
|
|
|
119
119
|
Error(`Replace key cannot be computed: '${keyPath.toString()}'`),
|
|
120
120
|
];
|
|
121
121
|
|
|
122
|
-
return [
|
|
123
|
-
null,
|
|
124
|
-
key,
|
|
125
|
-
];
|
|
122
|
+
return [null, key];
|
|
126
123
|
}
|
|
127
124
|
|
|
128
125
|
function hasMatch(path) {
|
|
129
|
-
const {body} = path.scope
|
|
130
|
-
.getProgramParent().path.node;
|
|
126
|
+
const {body} = path.scope.getProgramParent().path.node;
|
|
131
127
|
|
|
132
128
|
for (const current of body) {
|
|
133
129
|
if (compare(current, 'module.exports.match = __a'))
|
|
@@ -17,17 +17,20 @@ module.exports.report = () => {
|
|
|
17
17
|
|
|
18
18
|
function isRequire(path) {
|
|
19
19
|
return path
|
|
20
|
-
.get('callee')
|
|
20
|
+
.get('callee')
|
|
21
|
+
.isIdentifier({
|
|
21
22
|
name: 'require',
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
function isBabelTypes(path) {
|
|
26
27
|
return path
|
|
27
|
-
.get('arguments.0')
|
|
28
|
+
.get('arguments.0')
|
|
29
|
+
.isStringLiteral({
|
|
28
30
|
value: '@babel/types',
|
|
29
31
|
});
|
|
30
32
|
}
|
|
33
|
+
|
|
31
34
|
module.exports.traverse = ({push}) => ({
|
|
32
35
|
CallExpression(path) {
|
|
33
36
|
if (!isRequire(path))
|
|
@@ -12,9 +12,7 @@ module.exports.match = () => ({
|
|
|
12
12
|
'module.exports.traverse = (__args) => __a': ({__args}, path) => {
|
|
13
13
|
const program = path.scope.getProgramParent().path;
|
|
14
14
|
|
|
15
|
-
const withFix = contains(program, [
|
|
16
|
-
'module.exports.fix = __a',
|
|
17
|
-
]);
|
|
15
|
+
const withFix = contains(program, ['module.exports.fix = __a']);
|
|
18
16
|
|
|
19
17
|
if (withFix)
|
|
20
18
|
return false;
|
|
@@ -25,9 +23,7 @@ module.exports.match = () => ({
|
|
|
25
23
|
if (!__args.length)
|
|
26
24
|
return true;
|
|
27
25
|
|
|
28
|
-
const withPush = contains(__args[0], [
|
|
29
|
-
'push',
|
|
30
|
-
]);
|
|
26
|
+
const withPush = contains(__args[0], ['push']);
|
|
31
27
|
|
|
32
28
|
if (withPush)
|
|
33
29
|
return false;
|
|
@@ -61,8 +61,7 @@ module.exports.replace = () => ({
|
|
|
61
61
|
const buildRequire = template(`const NAME = REQUIRE`);
|
|
62
62
|
|
|
63
63
|
function declareRequire({__a, __b}, path) {
|
|
64
|
-
const shortName = __a.value || __a.name
|
|
65
|
-
.split('/').pop();
|
|
64
|
+
const shortName = __a.value || __a.name.split('/').pop();
|
|
66
65
|
|
|
67
66
|
const name = justCamelCase(shortName);
|
|
68
67
|
|
|
@@ -74,8 +73,7 @@ function declareRequire({__a, __b}, path) {
|
|
|
74
73
|
if (path.scope.hasBinding(name))
|
|
75
74
|
return name;
|
|
76
75
|
|
|
77
|
-
const programPath = path.scope
|
|
78
|
-
.getProgramParent().path;
|
|
76
|
+
const programPath = path.scope.getProgramParent().path;
|
|
79
77
|
|
|
80
78
|
programPath.node.body.unshift(requireNode);
|
|
81
79
|
|
|
@@ -10,6 +10,7 @@ module.exports.report = ({correct, operatorPath}) => {
|
|
|
10
10
|
|
|
11
11
|
module.exports.fix = ({path, incorrect, correct}) => {
|
|
12
12
|
path.node.value = path.node.value.replace(incorrect, correct);
|
|
13
|
+
path.node.raw = path.node.raw.replace(incorrect, correct);
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
module.exports.traverse = ({push}) => ({
|
|
@@ -72,8 +73,5 @@ function isCorrect({path, incorrect}) {
|
|
|
72
73
|
const {value} = messagePath.node;
|
|
73
74
|
const is = !incorrect.test(value);
|
|
74
75
|
|
|
75
|
-
return [
|
|
76
|
-
is,
|
|
77
|
-
messagePath,
|
|
78
|
-
];
|
|
76
|
+
return [is, messagePath];
|
|
79
77
|
}
|
package/package.json
CHANGED