@putout/plugin-putout 22.3.0 → 22.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.
|
@@ -33,7 +33,9 @@ module.exports.replace = () => ({
|
|
|
33
33
|
't.noTransform(__a)': transform,
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
const isTest = (path) => compare(path, 'test(__a, (t) => __body)'
|
|
36
|
+
const isTest = (path) => compare(path, 'test(__a, (t) => __body)', {
|
|
37
|
+
findUp: false,
|
|
38
|
+
});
|
|
37
39
|
|
|
38
40
|
const check = ({__a}, path) => {
|
|
39
41
|
const name = __a.value;
|
|
@@ -41,20 +43,14 @@ const check = ({__a}, path) => {
|
|
|
41
43
|
if (FIXTURE.includes(name))
|
|
42
44
|
return false;
|
|
43
45
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
if (!testPath)
|
|
47
|
-
return false;
|
|
48
|
-
|
|
49
|
-
const [str] = testPath.parentPath.parentPath.node.arguments;
|
|
46
|
+
const str = getTestNodeArgument(name, path);
|
|
50
47
|
|
|
51
48
|
return !str.value.includes(name);
|
|
52
49
|
};
|
|
53
50
|
|
|
54
51
|
const transform = ({__a}, path) => {
|
|
55
52
|
const name = __a.value;
|
|
56
|
-
const
|
|
57
|
-
const [str] = testPath.parentPath.parentPath.node.arguments;
|
|
53
|
+
const str = getTestNodeArgument(name, path);
|
|
58
54
|
|
|
59
55
|
const values = str.value.split(':');
|
|
60
56
|
const last = values
|
|
@@ -68,3 +64,17 @@ const transform = ({__a}, path) => {
|
|
|
68
64
|
|
|
69
65
|
return path;
|
|
70
66
|
};
|
|
67
|
+
|
|
68
|
+
const getTestNodeArgument = (value, path) => {
|
|
69
|
+
let testPath = path.find(isTest);
|
|
70
|
+
|
|
71
|
+
if (!testPath)
|
|
72
|
+
return {
|
|
73
|
+
value,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
if (testPath.isExpressionStatement())
|
|
77
|
+
testPath = testPath.get('expression');
|
|
78
|
+
|
|
79
|
+
return testPath.node.arguments[0];
|
|
80
|
+
};
|
package/package.json
CHANGED