@putout/plugin-putout 12.2.0 → 12.4.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/index.js +1 -2
- 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 +3 -4
- package/lib/convert-traverse-to-replace/index.js +2 -6
- package/lib/create-test/index.js +2 -3
- 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
|
@@ -126,8 +126,7 @@ function parseKey(propertyPath) {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
function hasMatch(path) {
|
|
129
|
-
const {body} = path.scope
|
|
130
|
-
.getProgramParent().path.node;
|
|
129
|
+
const {body} = path.scope.getProgramParent().path.node;
|
|
131
130
|
|
|
132
131
|
for (const current of body) {
|
|
133
132
|
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))
|
|
@@ -9,10 +9,9 @@ const {
|
|
|
9
9
|
const {StringLiteral} = types;
|
|
10
10
|
const {compare} = operator;
|
|
11
11
|
|
|
12
|
-
const isPush = (path) => path
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
12
|
+
const isPush = (path) => path.get('value').isIdentifier({
|
|
13
|
+
name: 'push',
|
|
14
|
+
});
|
|
16
15
|
|
|
17
16
|
module.exports.report = () => 'Includer should be used instead of Traverser';
|
|
18
17
|
|
|
@@ -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;
|
package/lib/create-test/index.js
CHANGED
|
@@ -19,12 +19,11 @@ const {
|
|
|
19
19
|
getProperty,
|
|
20
20
|
} = operator;
|
|
21
21
|
|
|
22
|
-
const selector = 'createTest(__dirname, __object)';
|
|
23
|
-
|
|
24
22
|
module.exports.report = () => `Apply modifications to 'createTest()' options`;
|
|
25
23
|
|
|
26
24
|
module.exports.include = () => [
|
|
27
|
-
|
|
25
|
+
'createTest(__dirname, __object)',
|
|
26
|
+
'createTest(import.meta.url, __object)',
|
|
28
27
|
];
|
|
29
28
|
|
|
30
29
|
module.exports.fix = (path, {options}) => {
|
|
@@ -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