@putout/plugin-putout 23.16.0 → 24.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 +28 -0
- package/lib/add-await-to-progress/index.js +4 -5
- package/lib/add-index-to-import/index.js +6 -10
- package/lib/add-path-arg-to-fix/index.js +4 -5
- package/lib/add-path-arg-to-visitors/index.js +4 -5
- package/lib/add-places-to-compare-places/index.js +2 -4
- package/lib/add-test-args/index.js +12 -3
- package/lib/add-track-file/index.js +12 -3
- package/lib/add-traverse-args/index.js +6 -7
- package/lib/apply-async-formatter/index.js +3 -4
- package/lib/apply-create-nested-directory/index.js +4 -5
- package/lib/apply-create-test/index.js +2 -4
- package/lib/apply-declare/index.js +2 -4
- package/lib/apply-exports-to-add-args/index.js +12 -0
- package/lib/apply-fixture-name-to-message/index.js +4 -5
- package/lib/apply-for-of-to-track-file/index.js +2 -4
- package/lib/apply-insert-after/index.js +2 -4
- package/lib/apply-insert-before/index.js +2 -4
- package/lib/apply-lowercase-to-node-builders/index.js +4 -5
- package/lib/apply-namespace-specifier/index.js +5 -7
- package/lib/apply-parens/index.js +2 -4
- package/lib/apply-processors-destructuring/index.js +2 -4
- package/lib/apply-remove/index.js +2 -4
- package/lib/apply-rename/index.js +2 -4
- package/lib/apply-report/index.js +3 -4
- package/lib/apply-short-processors/index.js +4 -6
- package/lib/apply-vars/index.js +4 -5
- package/lib/check-declare/index.js +5 -8
- package/lib/check-match/index.js +4 -6
- package/lib/check-replace-code/generate-code/index.js +5 -8
- package/lib/check-replace-code/generate-code/plugin-generate.js +4 -6
- package/lib/check-replace-code/index.js +7 -9
- package/lib/convert-add-argument-to-add-args/index.js +3 -4
- package/lib/convert-babel-types/index.js +4 -6
- package/lib/convert-destructuring-to-identifier/index.js +5 -5
- package/lib/convert-dirname-to-url/index.js +4 -5
- package/lib/convert-find-to-traverse/index.js +4 -6
- package/lib/convert-get-rule-to-require/index.js +9 -11
- package/lib/convert-include-to-traverse/index.js +4 -5
- package/lib/convert-match-to-function/index.js +2 -4
- package/lib/convert-method-to-property/index.js +5 -7
- package/lib/convert-node-to-path-in-get-template-values/index.js +4 -6
- package/lib/convert-number-to-numeric/index.js +4 -5
- package/lib/convert-process-to-find/index.js +4 -4
- package/lib/convert-progress-to-track-file/index.js +4 -6
- package/lib/convert-putout-test-to-create-test/index.js +5 -6
- package/lib/convert-replace-to-function/index.js +2 -4
- package/lib/convert-replace-with/index.js +6 -8
- package/lib/convert-replace-with-multiple/index.js +5 -7
- package/lib/convert-report-to-function/index.js +4 -5
- package/lib/convert-to-no-transform-code/index.js +4 -5
- package/lib/convert-traverse-to-include/index.js +5 -7
- package/lib/convert-traverse-to-replace/index.js +4 -5
- package/lib/convert-traverse-to-scan/index.js +5 -7
- package/lib/convert-url-to-dirname/index.js +4 -5
- package/lib/create-test/index.js +5 -6
- package/lib/declare/get-rule.js +4 -4
- package/lib/declare/index.js +4 -6
- package/lib/declare/operator/filesystem.js +1 -3
- package/lib/declare/operator/index.js +5 -7
- package/lib/declare/operator/json.js +1 -3
- package/lib/declare/operator/keyword.js +1 -3
- package/lib/declare/operator/parens.js +1 -3
- package/lib/declare/types.js +1179 -0
- package/lib/declare-path-variable/index.js +4 -5
- package/lib/declare-template-variables/index.js +4 -5
- package/lib/includer/index.js +2 -4
- package/lib/index.js +68 -68
- package/lib/move-require-on-top-level/index.js +5 -7
- package/lib/remove-empty-array-from-process/index.js +2 -4
- package/lib/remove-unused-get-properties-argument/index.js +4 -5
- package/lib/remove-useless-printer-option/index.js +4 -5
- package/lib/rename-operate-to-operator/index.js +5 -6
- package/lib/replace-operate-with-operator/index.js +2 -4
- package/lib/replace-test-message/index.js +4 -5
- package/lib/shorten-imports/index.js +2 -4
- package/lib/simplify-replace-template/index.js +5 -6
- package/package.json +7 -7
- package/lib/declare/types.json +0 -1179
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ npm i @putout/plugin-putout -D
|
|
|
25
25
|
- ✅ [apply-create-test](#apply-create-test);
|
|
26
26
|
- ✅ [apply-create-nested-directory](#apply-create-nested-directory);
|
|
27
27
|
- ✅ [apply-declare](#apply-declare);
|
|
28
|
+
- ✅ [apply-exports-to-add-args](#apply-exports-to-add-args);
|
|
28
29
|
- ✅ [apply-for-of-to-track-file](#apply-for-of-to-track-file);
|
|
29
30
|
- ✅ [apply-fixture-name-to-message](#apply-fixture-name-to-message);
|
|
30
31
|
- ✅ [apply-insert-after](#apply-insert-after);
|
|
@@ -96,6 +97,7 @@ npm i @putout/plugin-putout -D
|
|
|
96
97
|
"putout/apply-create-nested-directory": "on",
|
|
97
98
|
"putout/apply-async-formatter": "on",
|
|
98
99
|
"putout/apply-declare": "on",
|
|
100
|
+
"putout/apply-exports-to-add-args": "on",
|
|
99
101
|
"putout/apply-report": "on",
|
|
100
102
|
"putout/apply-processors-destructuring": "on",
|
|
101
103
|
"putout/apply-rename": "on",
|
|
@@ -456,6 +458,32 @@ module.exports.declare = () => ({
|
|
|
456
458
|
});
|
|
457
459
|
```
|
|
458
460
|
|
|
461
|
+
## apply-exports-to-add-args
|
|
462
|
+
|
|
463
|
+
Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/cf35de5e80e8f7aad866358a50c5eded/0af6142fc9c9e71ac2a2aa96cb85613dd95c9fbf).
|
|
464
|
+
|
|
465
|
+
### ❌ Example of incorrect code
|
|
466
|
+
|
|
467
|
+
```js
|
|
468
|
+
export default addArgs(__args);
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### ✅ Example of correct code
|
|
472
|
+
|
|
473
|
+
```js
|
|
474
|
+
const {
|
|
475
|
+
report,
|
|
476
|
+
fix,
|
|
477
|
+
traverse,
|
|
478
|
+
} = addArgs(__args);
|
|
479
|
+
|
|
480
|
+
export {
|
|
481
|
+
report,
|
|
482
|
+
fix,
|
|
483
|
+
traverse,
|
|
484
|
+
};
|
|
485
|
+
```
|
|
486
|
+
|
|
459
487
|
## apply-async-formatter
|
|
460
488
|
|
|
461
489
|
### ❌ Example of incorrect code
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {types, operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types, operator} = require('putout');
|
|
4
3
|
const {
|
|
5
4
|
objectProperty,
|
|
6
5
|
objectPattern,
|
|
@@ -17,14 +16,14 @@ const checkAwait = (vars, path) => {
|
|
|
17
16
|
return !path.parentPath.isAwaitExpression();
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
export const report = () => `Add 'await' to operator 'progress()'`;
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
export const match = () => ({
|
|
23
22
|
'progress(__args)': checkAwait,
|
|
24
23
|
't.progress(__args)': checkAwait,
|
|
25
24
|
});
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
export const replace = () => ({
|
|
28
27
|
'test(__a, async (t, {progress}) => __body)': 'test(__a, async ({progress}) => __body)',
|
|
29
28
|
'progress(__args)': addAwait,
|
|
30
29
|
't.progress(__args)': addAwait,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const {
|
|
5
|
-
traverse,
|
|
6
|
-
setLiteralValue,
|
|
7
|
-
} = operator;
|
|
3
|
+
const {setLiteralValue} = operator;
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
export const report = () => `Add 'index.js' to nested import`;
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
export const fix = (path) => {
|
|
12
8
|
const {source} = path.node;
|
|
13
9
|
const {value} = source;
|
|
14
10
|
|
|
@@ -20,7 +16,7 @@ module.exports.fix = (path) => {
|
|
|
20
16
|
setLiteralValue(source, `${value}/index.js`);
|
|
21
17
|
};
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
export const traverse = ({push, listStore}) => ({
|
|
24
20
|
'export const rules = __object': listStore,
|
|
25
21
|
'Program': {
|
|
26
22
|
exit: (path) => {
|
|
@@ -29,7 +25,7 @@ module.exports.traverse = ({push, listStore}) => ({
|
|
|
29
25
|
if (!rules.length)
|
|
30
26
|
return;
|
|
31
27
|
|
|
32
|
-
traverse(path, {
|
|
28
|
+
operator.traverse(path, {
|
|
33
29
|
ImportDeclaration: createImportVisitor(push),
|
|
34
30
|
});
|
|
35
31
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {compare} = operator;
|
|
5
4
|
const check = ({__a}) => {
|
|
6
5
|
if (__a.body)
|
|
@@ -9,14 +8,14 @@ const check = ({__a}) => {
|
|
|
9
8
|
return compare(__a, 'path.__()');
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
export const report = () => `Add 'path' argument to 'fix'`;
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
export const match = () => ({
|
|
15
14
|
'const fix = () => __a': check,
|
|
16
15
|
'module.exports.fix = () => __a': check,
|
|
17
16
|
});
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
export const replace = () => ({
|
|
20
19
|
'const fix = () => __a': 'const fix = (path) => __a',
|
|
21
20
|
'module.exports.fix = () => __a': 'module.exports.fix = (path) => __a',
|
|
22
21
|
});
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types} = require('putout');
|
|
4
3
|
const {identifier} = types;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => `Add 'path' argument to 'traverse' visitors`;
|
|
7
6
|
|
|
8
7
|
const TRAVERSE = '(__args) => __object';
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
export const fix = (path) => {
|
|
11
10
|
path.node.params.push(identifier('path'));
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
export const traverse = ({push}) => ({
|
|
15
14
|
[`export const traverse = ${TRAVERSE}`]: traverseMethods({
|
|
16
15
|
where: 'declaration.declarations.0.init',
|
|
17
16
|
push,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `Add 'places' array to 'comparePlaces()'`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'comparePlaces(__a)': 'comparePlaces(__a, [])',
|
|
7
5
|
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {addArgs} = operator;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
const {
|
|
6
|
+
report,
|
|
7
|
+
fix,
|
|
8
|
+
traverse,
|
|
9
|
+
} = addArgs({
|
|
7
10
|
comparePlaces: ['{comparePlaces}', [
|
|
8
11
|
'test("__a", async (__args) => __body)',
|
|
9
12
|
'test.skip("__a", async (__args) => __body)',
|
|
@@ -25,3 +28,9 @@ module.exports = addArgs({
|
|
|
25
28
|
'test.only("__a", async (__args) => __body)',
|
|
26
29
|
]],
|
|
27
30
|
});
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
report,
|
|
34
|
+
fix,
|
|
35
|
+
traverse,
|
|
36
|
+
};
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {addArgs} = operator;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
const {
|
|
6
|
+
report,
|
|
7
|
+
fix,
|
|
8
|
+
traverse,
|
|
9
|
+
} = addArgs({
|
|
7
10
|
trackFile: ['{trackFile}', [
|
|
8
11
|
'(__a, __b) => __body',
|
|
9
12
|
'(__a) => __body',
|
|
10
13
|
]],
|
|
11
14
|
});
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
report,
|
|
18
|
+
fix,
|
|
19
|
+
traverse,
|
|
20
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {types, operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types, operator} = require('putout');
|
|
4
3
|
const {
|
|
5
4
|
objectPattern,
|
|
6
5
|
objectProperty,
|
|
@@ -8,7 +7,7 @@ const {
|
|
|
8
7
|
isObjectPattern,
|
|
9
8
|
} = types;
|
|
10
9
|
|
|
11
|
-
const {
|
|
10
|
+
const {getBinding} = operator;
|
|
12
11
|
|
|
13
12
|
const defaultNames = [
|
|
14
13
|
'push',
|
|
@@ -18,9 +17,9 @@ const defaultNames = [
|
|
|
18
17
|
'options',
|
|
19
18
|
];
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
export const report = ({name}) => `Add '${name}' argument to 'traverse'`;
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
export const fix = ({name, fn}) => {
|
|
24
23
|
const computed = false;
|
|
25
24
|
const shorthand = true;
|
|
26
25
|
const id = identifier(name);
|
|
@@ -34,7 +33,7 @@ module.exports.fix = ({name, fn}) => {
|
|
|
34
33
|
fn.params[0].properties.push(property);
|
|
35
34
|
};
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
export const traverse = ({push, options}) => {
|
|
38
37
|
const {
|
|
39
38
|
names = defaultNames,
|
|
40
39
|
} = options;
|
|
@@ -67,7 +66,7 @@ const isArgExists = (mainName, fn) => {
|
|
|
67
66
|
const checkArgs = (names, push) => (path) => {
|
|
68
67
|
const fn = parseFn(path);
|
|
69
68
|
|
|
70
|
-
traverse(path, {
|
|
69
|
+
operator.traverse(path, {
|
|
71
70
|
ReferencedIdentifier(path) {
|
|
72
71
|
const {name} = path.node;
|
|
73
72
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator, types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator, types} = require('putout');
|
|
4
3
|
const {
|
|
5
4
|
objectProperty,
|
|
6
5
|
objectPattern,
|
|
@@ -12,9 +11,9 @@ const shorthand = true;
|
|
|
12
11
|
|
|
13
12
|
const {compare} = operator;
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
export const report = () => 'Use Async API to test Formatter';
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
export const replace = () => ({
|
|
18
17
|
't.format(__args)': create('format'),
|
|
19
18
|
't.noFormat(__args)': create('noFormat'),
|
|
20
19
|
't.formatMany(__args)': create('formatMany'),
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types} = require('putout');
|
|
4
3
|
const {isStringLiteral} = types;
|
|
5
4
|
|
|
6
5
|
const NESTED = {
|
|
@@ -8,12 +7,12 @@ const NESTED = {
|
|
|
8
7
|
createNestedDirectory: 'createDirectory',
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
export const report = (path) => {
|
|
12
11
|
const {name} = path.node.callee;
|
|
13
12
|
return `Use '${NESTED[name]}()' instead of '${name}()'`;
|
|
14
13
|
};
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
export const match = () => ({
|
|
17
16
|
'createDirectory(__a, __b)': ({__b}) => {
|
|
18
17
|
if (!isStringLiteral(__b))
|
|
19
18
|
return false;
|
|
@@ -28,7 +27,7 @@ module.exports.match = () => ({
|
|
|
28
27
|
},
|
|
29
28
|
});
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
export const replace = () => ({
|
|
32
31
|
'createDirectory(__a, __b)': 'createNestedDirectory(__a, __b)',
|
|
33
32
|
'createNestedDirectory(__a, __b)': 'createDirectory(__a, __b)',
|
|
34
33
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export const report = () => `Apply 'createTest'`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'require("@putout/test")(__dirname, __a)': `createTest(__dirname, __a)`,
|
|
7
5
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `Use 'Declarator' instead of 'operator.declare()'`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'module.exports = declare(__a)': 'module.exports.declare = () => __a',
|
|
7
5
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {
|
|
5
4
|
setLiteralValue,
|
|
6
5
|
compare,
|
|
@@ -17,9 +16,9 @@ const NAMES = [
|
|
|
17
16
|
'no transform',
|
|
18
17
|
];
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
export const report = () => `Apply 'fixture' name to 'message'`;
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
export const match = () => ({
|
|
23
22
|
't.noReport(__a)': check,
|
|
24
23
|
't.report(__a, __b)': check,
|
|
25
24
|
't.transform(__a)': check,
|
|
@@ -27,7 +26,7 @@ module.exports.match = () => ({
|
|
|
27
26
|
't.noTransform(__a)': check,
|
|
28
27
|
});
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
export const replace = () => ({
|
|
31
30
|
't.noReport(__a)': transform,
|
|
32
31
|
't.report(__a, __b)': transform,
|
|
33
32
|
't.transform(__a)': transform,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `Use 'if condition' instead of 'ternary expression'`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'trackFile(__a, __b).map(push)': 'for (const file of trackFile( __a, __b)) {push(file)}',
|
|
7
5
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `Use 'insertAfter(a, b)' instead of 'a.insertAfter(b)'`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'__a.insertAfter(__b)': 'insertAfter(__a, __b)',
|
|
7
5
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `Use 'insertBefore(a, b)' instead of 'a.insertBefore(b)'`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'__a.insertBefore(__b)': 'insertBefore(__a, __b)',
|
|
7
5
|
});
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types} = require('putout');
|
|
4
3
|
const {isIdentifier} = types;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => `Use lowercased node builders`;
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export const fix = (path) => {
|
|
9
8
|
const [first] = path.node.name;
|
|
10
9
|
const other = path.node.name.slice(1);
|
|
11
10
|
|
|
12
11
|
path.node.name = first.toLowerCase() + other;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
export const traverse = ({push}) => ({
|
|
16
15
|
CallExpression(path) {
|
|
17
16
|
const calleePath = path.get('callee');
|
|
18
17
|
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
|
+
import {parseImportSpecifiers} from 'parse-import-specifiers';
|
|
2
3
|
|
|
3
|
-
const {types} = require('putout');
|
|
4
|
-
|
|
5
|
-
const {parseImportSpecifiers} = require('parse-import-specifiers');
|
|
6
4
|
const {isImportDeclaration} = types;
|
|
7
5
|
const noop = () => {};
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
export const report = () => `Use 'import * as plugin' instead of 'import plugin'`;
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
export const fix = ({first}) => {
|
|
12
10
|
first.node.type = 'ImportNamespaceSpecifier';
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
export const traverse = ({push, listStore, pathStore}) => ({
|
|
16
14
|
'export const rules = __object': listStore,
|
|
17
15
|
'import {createTest} from "@putout/test"': listStore,
|
|
18
16
|
...createImportVisitor({
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports.report = (path) => {
|
|
1
|
+
export const report = (path) => {
|
|
4
2
|
if (path.isOptionalMemberExpression())
|
|
5
3
|
return `Use 'hasParens(path)' instead of 'path.node.extra'`;
|
|
6
4
|
|
|
@@ -17,7 +15,7 @@ const ASSIGN_OBJECT = `
|
|
|
17
15
|
}
|
|
18
16
|
`;
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
export const replace = () => ({
|
|
21
19
|
'__a.node.extra.parenthesized = false': 'removeParens(__a)',
|
|
22
20
|
'__a.node.extra.parenthesized = true': 'addParens(__a)',
|
|
23
21
|
'__a.node.extra?.parenthesized': 'hasParens(__a)',
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => 'Test operator should be destructured';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'async (t) => {await t.process(__args)}': 'async ({process}) => {await process(__args)}',
|
|
7
5
|
'async (t) => {await t.noProcess(__args)}': 'async ({noProcess}) => {await noProcess(__args)}',
|
|
8
6
|
'async (t) => {await t.comparePlaces(__args)}': 'async ({comparePlaces}) => {await comparePlaces(__args)}',
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `Use 'remove(path)' instead of 'path.remove()'`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'__a.remove()': 'remove(__a)',
|
|
7
5
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `Use 'rename(path, from, to)' instead of 'path.scope.rename(from, to)'`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'__a.scope.rename(__b, __c)': 'rename(__a, __b, __c)',
|
|
7
5
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {compare} = operator;
|
|
5
4
|
const TYPES = {
|
|
6
5
|
noReport: 'noReportWithOptions',
|
|
@@ -8,7 +7,7 @@ const TYPES = {
|
|
|
8
7
|
noReportWithOptions: 'noReport',
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
export const report = (path) => {
|
|
12
11
|
const {name} = path.node.callee.property;
|
|
13
12
|
|
|
14
13
|
if (compare(path, 't.noReport(__a, "__b")'))
|
|
@@ -20,7 +19,7 @@ module.exports.report = (path) => {
|
|
|
20
19
|
return `Use 't.${TYPES[name]}()' instead of 't.${name}()'`;
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
export const replace = () => ({
|
|
24
23
|
't.noReport(__a, __object)': 't.noReportWithOptions(__a, __object)',
|
|
25
24
|
't.noReport(__a, __b)': 't.noReport(__a)',
|
|
26
25
|
't.report(__a)': 't.noReport(__a)',
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {types, operator} = require('putout');
|
|
1
|
+
import {types, operator} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {compute, rename} = operator;
|
|
6
4
|
const {identifier} = types;
|
|
@@ -14,12 +12,12 @@ const getShortName = (a) => {
|
|
|
14
12
|
.replace('putout_processor_', '');
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
export const report = ({value}) => {
|
|
18
16
|
const name = getShortName(value);
|
|
19
17
|
return `Use '[${name}]' instead of '${value}'`;
|
|
20
18
|
};
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
export const fix = ({path, value}) => {
|
|
23
21
|
const name = getShortName(value);
|
|
24
22
|
|
|
25
23
|
path.node.key = identifier(name);
|
|
@@ -27,7 +25,7 @@ module.exports.fix = ({path, value}) => {
|
|
|
27
25
|
rename(path.get('value'), '__a', chooseType(name));
|
|
28
26
|
};
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
export const traverse = ({push}) => ({
|
|
31
29
|
ObjectProperty(path) {
|
|
32
30
|
const [is, value] = compute(path.get('key'));
|
|
33
31
|
|
package/lib/apply-vars/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {compareAny} = operator;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => `Use 'vars' instead of '{}'`;
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export const match = () => ({
|
|
9
8
|
'({}, path) => __a': isInsideReplacer,
|
|
10
9
|
});
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
export const replace = () => ({
|
|
13
12
|
'({}, path) => __a': '(vars, path) => __a',
|
|
14
13
|
});
|
|
15
14
|
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const tryCatch = require('try-catch');
|
|
4
|
-
const putout = require('putout');
|
|
1
|
+
import tryCatch from 'try-catch';
|
|
2
|
+
import putout from 'putout';
|
|
5
3
|
|
|
6
4
|
const {types, operator} = putout;
|
|
7
5
|
|
|
8
|
-
const noop = () => {};
|
|
9
6
|
const {getTemplateValues} = operator;
|
|
10
7
|
|
|
11
8
|
const DECLARE_ESM = 'export const declare = () => __object';
|
|
@@ -17,10 +14,10 @@ const {
|
|
|
17
14
|
isStringLiteral,
|
|
18
15
|
} = types;
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
export const report = ({message}) => message;
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
export const fix = () => {};
|
|
20
|
+
export const traverse = ({push}) => ({
|
|
24
21
|
[DECLARE_ESM]: createCheck(push, DECLARE_ESM),
|
|
25
22
|
[DECLARE_COMMONJS]: createCheck(push, DECLARE_COMMONJS),
|
|
26
23
|
[COMMONJS]: createCheck(push, COMMONJS),
|
package/lib/check-match/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {operator, types} = require('putout');
|
|
1
|
+
import {operator, types} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {
|
|
6
4
|
getTemplateValues,
|
|
@@ -13,13 +11,13 @@ const PATTERN_MATCH = 'module.exports.match = () => __object';
|
|
|
13
11
|
const PATTERN_REPLACE = 'module.exports.replace = () => __object';
|
|
14
12
|
const PATTERN_REPLACE_RETURN = 'module.exports.replace = (__args) => __body';
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export const report = () => `☝️ Looks like 'match()' template absent in 'replace()'`;
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
export const replace = () => ({
|
|
19
17
|
[PATTERN_MATCH]: PATTERN_MATCH,
|
|
20
18
|
});
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
export const match = () => ({
|
|
23
21
|
[PATTERN_MATCH]: ({__object}, path) => {
|
|
24
22
|
const namesMatch = getNames(__object);
|
|
25
23
|
const namesReplace = [];
|