@putout/plugin-putout 20.9.1 → 21.0.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
CHANGED
|
@@ -89,7 +89,9 @@ npm i @putout/plugin-putout -D
|
|
|
89
89
|
"putout/add-await-to-progress": "on",
|
|
90
90
|
"putout/add-index-to-import": "on",
|
|
91
91
|
"putout/check-match": "on",
|
|
92
|
-
"putout/check-replace-code": "on",
|
|
92
|
+
"putout/check-replace-code": ["on", {
|
|
93
|
+
"once": true
|
|
94
|
+
}],
|
|
93
95
|
"putout/convert-putout-test-to-create-test": "on",
|
|
94
96
|
"putout/convert-to-no-transform-code": "on",
|
|
95
97
|
"putout/convert-number-to-numeric": "on",
|
|
@@ -743,6 +745,7 @@ module.exports.match = () => ({
|
|
|
743
745
|
## check-replace-code
|
|
744
746
|
|
|
745
747
|
Checks that [Replacer](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#replacer) transform is possible.
|
|
748
|
+
Pass `once=false` to always fail no matter how many `fixCounts` passed.
|
|
746
749
|
|
|
747
750
|
### ❌ Example of incorrect code
|
|
748
751
|
|
|
@@ -6,6 +6,7 @@ const {
|
|
|
6
6
|
print,
|
|
7
7
|
transform,
|
|
8
8
|
} = require('putout');
|
|
9
|
+
|
|
9
10
|
const tryCatch = require('try-catch');
|
|
10
11
|
const generateCode = require('./generate-code');
|
|
11
12
|
const noop = () => {};
|
|
@@ -42,10 +43,20 @@ module.exports.fix = ({mainPath}) => {
|
|
|
42
43
|
set(mainPath);
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
module.exports.traverse = ({push}) =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
module.exports.traverse = ({push, options}) => {
|
|
47
|
+
const {once = true} = options;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
'module.exports.replace = () => __a': createTraverseReplacer({
|
|
51
|
+
once,
|
|
52
|
+
push,
|
|
53
|
+
}),
|
|
54
|
+
'export const replace = () => __a': createTraverseReplacer({
|
|
55
|
+
once,
|
|
56
|
+
push,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
};
|
|
49
60
|
|
|
50
61
|
function getProperties(path) {
|
|
51
62
|
const props = `body.properties`;
|
|
@@ -56,8 +67,8 @@ function getProperties(path) {
|
|
|
56
67
|
return path.get(`right.${props}`);
|
|
57
68
|
}
|
|
58
69
|
|
|
59
|
-
const createTraverseReplacer = (push) => (path) => {
|
|
60
|
-
if (get(path))
|
|
70
|
+
const createTraverseReplacer = ({once, push}) => (path) => {
|
|
71
|
+
if (once && get(path))
|
|
61
72
|
return;
|
|
62
73
|
|
|
63
74
|
if (hasMatch(path))
|
|
@@ -22,12 +22,14 @@ module.exports.match = () => ({
|
|
|
22
22
|
if (__aPath.isBlockStatement())
|
|
23
23
|
return false;
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const properties = __aPath.get('properties');
|
|
26
|
+
|
|
27
|
+
for (const propertyPath of properties) {
|
|
28
|
+
if (!isPush(propertyPath) && !isBlock(propertyPath))
|
|
29
|
+
return false;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
return
|
|
32
|
+
return true;
|
|
31
33
|
},
|
|
32
34
|
});
|
|
33
35
|
|
|
@@ -35,8 +37,9 @@ module.exports.replace = () => ({
|
|
|
35
37
|
'module.exports.traverse = __a': (vars, path) => {
|
|
36
38
|
const node = template.ast.fresh('module.exports.include = () => []');
|
|
37
39
|
const __aPath = path.get('right.body');
|
|
40
|
+
const properties = __aPath.get('properties');
|
|
38
41
|
|
|
39
|
-
for (const propertyPath of
|
|
42
|
+
for (const propertyPath of properties) {
|
|
40
43
|
const name = getName(propertyPath);
|
|
41
44
|
|
|
42
45
|
if (isPush(propertyPath) || isBlock(propertyPath)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.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",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"fullstore": "^3.0.0",
|
|
29
|
-
"just-camel-case": "^6.0
|
|
29
|
+
"just-camel-case": "^6.2.0",
|
|
30
30
|
"parse-import-specifiers": "^1.0.2",
|
|
31
31
|
"try-catch": "^3.0.0"
|
|
32
32
|
},
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@putout/plugin-tape": "*",
|
|
41
|
-
"@putout/test": "^
|
|
41
|
+
"@putout/test": "^11.0.0",
|
|
42
42
|
"c8": "^10.0.0",
|
|
43
43
|
"eslint": "^9.0.0",
|
|
44
44
|
"eslint-plugin-n": "^17.0.0",
|
|
45
|
-
"eslint-plugin-putout": "^
|
|
45
|
+
"eslint-plugin-putout": "^23.0.0",
|
|
46
46
|
"lerna": "^6.0.1",
|
|
47
47
|
"madrun": "^10.0.0",
|
|
48
48
|
"montag": "^1.2.1",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"supertape": "^10.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"putout": ">=
|
|
53
|
+
"putout": ">=36"
|
|
54
54
|
},
|
|
55
55
|
"license": "MIT",
|
|
56
56
|
"engines": {
|