@putout/plugin-putout 23.15.1 → 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 +2 -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
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import {
|
|
4
2
|
parse,
|
|
5
3
|
print,
|
|
6
4
|
transform,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const pluginGenerate = require('./plugin-generate');
|
|
5
|
+
} from 'putout';
|
|
6
|
+
import tryCatch from 'try-catch';
|
|
7
|
+
import * as pluginGenerate from './plugin-generate.js';
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
export default (rootPath, source) => {
|
|
13
10
|
const [parseError, ast] = tryCatch(parse, source, {
|
|
14
11
|
isTS: true,
|
|
15
12
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator, types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator, types} = require('putout');
|
|
4
3
|
const {
|
|
5
4
|
objectPattern,
|
|
6
5
|
objectExpression,
|
|
@@ -11,16 +10,15 @@ const {
|
|
|
11
10
|
} = types;
|
|
12
11
|
|
|
13
12
|
const {replaceWith} = operator;
|
|
14
|
-
const noop = () => {};
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export const report = () => {};
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
export const include = () => [
|
|
19
17
|
'Identifier',
|
|
20
18
|
'StringLiteral',
|
|
21
19
|
];
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
export const fix = (path, {options}) => {
|
|
24
22
|
const {getVar} = options;
|
|
25
23
|
const {node} = path;
|
|
26
24
|
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import tryCatch from 'try-catch';
|
|
2
|
+
import {
|
|
4
3
|
operator,
|
|
5
4
|
parse,
|
|
6
5
|
print,
|
|
7
6
|
transform,
|
|
8
|
-
}
|
|
7
|
+
} from 'putout';
|
|
8
|
+
import generateCode from './generate-code/index.js';
|
|
9
9
|
|
|
10
|
-
const tryCatch = require('try-catch');
|
|
11
|
-
const generateCode = require('./generate-code');
|
|
12
10
|
const noop = () => {};
|
|
13
11
|
|
|
14
12
|
const {
|
|
@@ -29,7 +27,7 @@ const rmSemi = (a) => {
|
|
|
29
27
|
return a;
|
|
30
28
|
};
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
export const report = ({path, code, error}) => {
|
|
33
31
|
if (error)
|
|
34
32
|
return error.message;
|
|
35
33
|
|
|
@@ -39,11 +37,11 @@ module.exports.report = ({path, code, error}) => {
|
|
|
39
37
|
return `transform mismatch: "${key}" -> "${value}" !== "${code}"`;
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
export const fix = ({mainPath}) => {
|
|
43
41
|
set(mainPath);
|
|
44
42
|
};
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
export const traverse = ({push, options}) => {
|
|
47
45
|
const {once = true} = options;
|
|
48
46
|
|
|
49
47
|
return {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {rename} = operator;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => 'Use addArgs instead of addArgument';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export const replace = () => ({
|
|
9
8
|
'addArgument(__args)': (vars, path) => {
|
|
10
9
|
const program = path.scope.getProgramParent().path;
|
|
11
10
|
rename(program, 'addArgument', 'addArgs');
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {operator, template} = require('putout');
|
|
1
|
+
import {operator, template} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {replaceWith} = operator;
|
|
6
4
|
|
|
@@ -8,7 +6,7 @@ const astRequire = template.ast(`
|
|
|
8
6
|
require('putout').types
|
|
9
7
|
`);
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
export const report = () => {
|
|
12
10
|
return `"putout.types" should be used instead of "@babel/types"`;
|
|
13
11
|
};
|
|
14
12
|
|
|
@@ -20,7 +18,7 @@ const isBabelTypes = (path) => path.get('arguments.0').isStringLiteral({
|
|
|
20
18
|
value: '@babel/types',
|
|
21
19
|
});
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
export const traverse = ({push}) => ({
|
|
24
22
|
CallExpression(path) {
|
|
25
23
|
if (!isRequire(path))
|
|
26
24
|
return;
|
|
@@ -32,6 +30,6 @@ module.exports.traverse = ({push}) => ({
|
|
|
32
30
|
},
|
|
33
31
|
});
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
export const fix = (path) => {
|
|
36
34
|
replaceWith(path, astRequire);
|
|
37
35
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {compare} =
|
|
3
|
+
const {compare} = operator;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export const report = () => 'Identifier should be used instead of empty destructuring';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const match = () => ({
|
|
8
8
|
'({}) => __body': (vars, path) => findUp(path, 'module.exports.__a = __'),
|
|
9
9
|
'({}, __a) => __body': (vars, path) => findUp(path, 'module.exports.__a = __'),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
export const replace = () => ({
|
|
13
13
|
'({}) => __body': '(vars) => __body',
|
|
14
14
|
'({}, __a) => __body': '(vars, __a) => __body',
|
|
15
15
|
});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {isESM} = operator;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => `Use 'createTest(import.meta.url)' instead of 'createTest(__dirname)'`;
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export const match = () => ({
|
|
9
8
|
'createTest(__dirname, __a)': (vars, path) => isESM(path),
|
|
10
9
|
});
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
export const replace = () => ({
|
|
13
12
|
'createTest(__dirname, __a)': 'createTest(import.meta.url, __a)',
|
|
14
13
|
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {types, operator} = require('putout');
|
|
1
|
+
import {types, operator} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {replaceWith} = operator;
|
|
6
4
|
|
|
@@ -12,7 +10,7 @@ const {
|
|
|
12
10
|
|
|
13
11
|
const {entries} = Object;
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
export const report = () => '"traverse" should be used instead of "find"';
|
|
16
14
|
|
|
17
15
|
const fixType = (types) => (path) => {
|
|
18
16
|
for (const [is, fix] of entries(types)) {
|
|
@@ -21,7 +19,7 @@ const fixType = (types) => (path) => {
|
|
|
21
19
|
}
|
|
22
20
|
};
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
export const fix = fixType({
|
|
25
23
|
isMemberExpression: (path) => {
|
|
26
24
|
path.get('property').node.name = 'traverse';
|
|
27
25
|
},
|
|
@@ -33,7 +31,7 @@ module.exports.fix = fixType({
|
|
|
33
31
|
},
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
export const traverse = ({push}) => ({
|
|
37
35
|
'module.exports.find = (__args) => __'(path) {
|
|
38
36
|
const leftPath = path.get('left');
|
|
39
37
|
const rightPath = path.get('right');
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import {
|
|
4
2
|
types,
|
|
5
3
|
operator,
|
|
6
4
|
template,
|
|
7
|
-
}
|
|
5
|
+
} from 'putout';
|
|
6
|
+
import camel from 'just-camel-case';
|
|
8
7
|
|
|
9
|
-
const camel = require('just-camel-case');
|
|
10
8
|
const {
|
|
11
9
|
stringLiteral,
|
|
12
10
|
arrayExpression,
|
|
@@ -21,19 +19,19 @@ const {
|
|
|
21
19
|
getPathAfterRequires,
|
|
22
20
|
} = operator;
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
export const report = () => `Use top-level 'require()' instead of '...getRule()'`;
|
|
25
23
|
|
|
26
24
|
const REQUIRE = `const __a = require(__b)`;
|
|
27
25
|
const createRequire = template(REQUIRE, {
|
|
28
26
|
placeholderPattern: /__/,
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
'getRule(__a)':
|
|
33
|
-
'getRule(__a, __b)':
|
|
29
|
+
export const match = () => ({
|
|
30
|
+
'getRule(__a)': runMatch,
|
|
31
|
+
'getRule(__a, __b)': runMatch,
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
export const replace = () => ({
|
|
37
35
|
'getRule(__a)': ({__a}, path) => {
|
|
38
36
|
const name = camel(__a.value);
|
|
39
37
|
const id = identifier(name);
|
|
@@ -86,7 +84,7 @@ function addRequire({__a, id, path}) {
|
|
|
86
84
|
programPath.node.body.unshift(nodeRequire);
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
function
|
|
87
|
+
function runMatch({__a}, path) {
|
|
90
88
|
const name = __a.value;
|
|
91
89
|
|
|
92
90
|
if (!path.parentPath.isSpreadElement())
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types} = require('putout');
|
|
4
3
|
const {isObjectExpression} = types;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => `Use 'traverse' instead of 'include'`;
|
|
7
6
|
|
|
8
7
|
const check = ({__a}) => {
|
|
9
8
|
return isObjectExpression(__a.body);
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
export const match = () => ({
|
|
13
12
|
'const include = __a': check,
|
|
14
13
|
'module.exports.include = __a': check,
|
|
15
14
|
});
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
export const replace = () => ({
|
|
18
17
|
'const include = __a': 'const traverse = __a',
|
|
19
18
|
'module.exports.include = __a': 'module.exports.traverse = __a',
|
|
20
19
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `'match' should be a function`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'module.exports.match= __object': 'module.exports.match = () => __object',
|
|
7
5
|
});
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {types, operator} = require('putout');
|
|
1
|
+
import {types, operator} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {replaceWith} = operator;
|
|
6
4
|
const {objectProperty} = types;
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
export const report = () => 'Object Property should be used instead of Method';
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
export const include = () => [
|
|
11
9
|
'ObjectMethod',
|
|
12
10
|
];
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
export const filter = (path) => {
|
|
15
13
|
if (!path.node.params.length)
|
|
16
14
|
return false;
|
|
17
15
|
|
|
@@ -23,7 +21,7 @@ module.exports.filter = (path) => {
|
|
|
23
21
|
return !firstPath.node.properties.length;
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
export const fix = (path) => {
|
|
27
25
|
const keyPath = path.get('key');
|
|
28
26
|
|
|
29
27
|
path.node.type = 'ArrowFunctionExpression';
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {types, operator} = require('putout');
|
|
1
|
+
import {types, operator} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {
|
|
6
4
|
compare,
|
|
@@ -13,11 +11,11 @@ const {
|
|
|
13
11
|
isArrayPattern,
|
|
14
12
|
} = types;
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export const report = () => '"path" should be used instead of "node" in getTemplateValues';
|
|
17
15
|
|
|
18
16
|
const GET_TEMPLATE_VALUES_NODE = 'getTemplateValues(__a.node, __b)';
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
export const fix = ({path, __aPath, init}) => {
|
|
21
19
|
if (compare(path, GET_TEMPLATE_VALUES_NODE)) {
|
|
22
20
|
const {__a} = getTemplateValues(path, GET_TEMPLATE_VALUES_NODE);
|
|
23
21
|
replaceWith(__aPath, __a);
|
|
@@ -28,7 +26,7 @@ module.exports.fix = ({path, __aPath, init}) => {
|
|
|
28
26
|
replaceWith(__aPath, init);
|
|
29
27
|
};
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
export const traverse = ({push}) => ({
|
|
32
30
|
'getTemplateValues(__a, __b)': (path) => {
|
|
33
31
|
const {scope} = path;
|
|
34
32
|
const {bindings} = scope;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {rename} = operator;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => `Use 'isNumericLiteral()' instead of 'isNumberLiteral()'`;
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export const fix = (path) => {
|
|
9
8
|
const bindings = path.scope.getAllBindings();
|
|
10
9
|
const {name} = path.node.callee;
|
|
11
10
|
const program = path.scope.getProgramParent().path;
|
|
@@ -19,7 +18,7 @@ module.exports.fix = (path) => {
|
|
|
19
18
|
path.node.callee.name = name.replace('Number', 'Numeric');
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
export const include = () => [
|
|
23
22
|
'isNumberLiteral(__a)',
|
|
24
23
|
'NumberLiteral(__a)',
|
|
25
24
|
];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {replaceWith} =
|
|
3
|
+
const {replaceWith} = operator;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export const report = () => 'Use find instead of process';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const replace = () => ({
|
|
8
8
|
'module.exports.preProcess = __a': 'module.exports.branch = __a',
|
|
9
9
|
'module.exports.postProcess = __a ': 'module.exports.merge = __a',
|
|
10
10
|
'module.exports.process = __a': (vars, path) => {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {operator, types} = require('putout');
|
|
1
|
+
import {operator, types} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {isForOfStatement} = types;
|
|
6
4
|
const {remove, replaceWith} = operator;
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
export const report = () => `Convert 'progress()' to 'trackFile()'`;
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
export const fix = ({path, statement}) => {
|
|
11
9
|
const {name} = statement.node.right.callee.object;
|
|
12
10
|
const nameBinding = path.scope.getAllBindings()[name];
|
|
13
11
|
const {init} = nameBinding.path.node;
|
|
@@ -22,7 +20,7 @@ module.exports.fix = ({path, statement}) => {
|
|
|
22
20
|
remove(path);
|
|
23
21
|
};
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
export const traverse = ({push}) => ({
|
|
26
24
|
'progress(__args)': (path) => {
|
|
27
25
|
const statement = path.find(isForOfStatement);
|
|
28
26
|
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {rename} = operator;
|
|
5
4
|
const {assign} = Object;
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export const report = () => `Use 'createTest' instead of 'putoutTest'`;
|
|
7
|
+
export const filter = ({scope}) => !scope.bindings.createTest;
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
export const include = () => [
|
|
11
10
|
'import putoutTest from "@putout/test"',
|
|
12
11
|
];
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
export const fix = (path) => {
|
|
15
14
|
const [first] = path.node.specifiers;
|
|
16
15
|
|
|
17
16
|
assign(first, {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => `'replace' should be a function`;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.replace = () => ({
|
|
3
|
+
export const replace = () => ({
|
|
6
4
|
'module.exports.replace = __object': 'module.exports.replace = () => __object',
|
|
7
5
|
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import {
|
|
4
2
|
operator,
|
|
5
3
|
template,
|
|
6
4
|
types,
|
|
7
|
-
}
|
|
5
|
+
} from 'putout';
|
|
6
|
+
import fullstore from 'fullstore';
|
|
8
7
|
|
|
9
|
-
const fullstore = require('fullstore');
|
|
10
8
|
const {objectProperty, identifier} = types;
|
|
11
9
|
|
|
12
10
|
const {
|
|
@@ -15,11 +13,11 @@ const {
|
|
|
15
13
|
insertBefore,
|
|
16
14
|
} = operator;
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
export const report = () => {
|
|
19
17
|
return `Use 'operator.replaceWith()' instead of 'path.replaceWith()'`;
|
|
20
18
|
};
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
export const fix = ({path, calleePath, property, object, program, isInserted}) => {
|
|
23
21
|
replaceWith(calleePath, property);
|
|
24
22
|
const {bindings} = program.scope;
|
|
25
23
|
|
|
@@ -65,7 +63,7 @@ function getVarPath(bindings) {
|
|
|
65
63
|
return insertAfter.path;
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
|
|
66
|
+
export const traverse = ({push}) => {
|
|
69
67
|
const isInserted = fullstore();
|
|
70
68
|
|
|
71
69
|
return {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import {
|
|
4
2
|
operator,
|
|
5
3
|
template,
|
|
6
4
|
types,
|
|
7
|
-
}
|
|
5
|
+
} from 'putout';
|
|
8
6
|
|
|
9
7
|
const {objectProperty, identifier} = types;
|
|
10
8
|
const {replaceWith, insertBefore} = operator;
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
export const report = () => {
|
|
13
11
|
return `"operate.replaceWithMultiple" should be called instead of "path.replaceWithMultiple"`;
|
|
14
12
|
};
|
|
15
13
|
|
|
@@ -17,7 +15,7 @@ const replaceWithAST = template.ast(`
|
|
|
17
15
|
const {replaceWithMultiple} = require('putout').operate;
|
|
18
16
|
`);
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
export const fix = ({path, calleePath, property, object, program}) => {
|
|
21
19
|
const first = program.get('body.0');
|
|
22
20
|
const {bindings} = program.scope;
|
|
23
21
|
|
|
@@ -45,7 +43,7 @@ function getVarPath(bindings) {
|
|
|
45
43
|
return insertAfter.path;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
|
|
46
|
+
export const traverse = ({push}) => ({
|
|
49
47
|
CallExpression(path) {
|
|
50
48
|
const calleePath = path.get('callee');
|
|
51
49
|
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types} = require('putout');
|
|
4
3
|
const {
|
|
5
4
|
isStringLiteral,
|
|
6
5
|
isTemplateLiteral,
|
|
7
6
|
} = types;
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
export const report = () => `Typeof 'report' should be a 'function'`;
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
export const match = () => ({
|
|
12
11
|
'module.exports.report = __a': ({__a}) => isStringLiteral(__a) || isTemplateLiteral(__a),
|
|
13
12
|
});
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
export const replace = () => ({
|
|
16
15
|
'module.exports.report = __a': 'module.exports.report = () => __a',
|
|
17
16
|
});
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types} = require('putout');
|
|
4
3
|
const {isIdentifier, identifier} = types;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => {
|
|
7
6
|
return `"noTransformCode" should be called instead of using same arguments twice in "transformCode"`;
|
|
8
7
|
};
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
export const traverse = ({push}) => ({
|
|
11
10
|
CallExpression(path) {
|
|
12
11
|
const calleePath = path.get('callee');
|
|
13
12
|
|
|
@@ -34,7 +33,7 @@ module.exports.traverse = ({push}) => ({
|
|
|
34
33
|
},
|
|
35
34
|
});
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
export const fix = ({path, calleePath}) => {
|
|
38
37
|
calleePath.node.property = identifier('noTransformCode');
|
|
39
38
|
path.node.arguments.pop();
|
|
40
39
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import {
|
|
4
2
|
types,
|
|
5
3
|
template,
|
|
6
4
|
operator,
|
|
7
|
-
}
|
|
5
|
+
} from 'putout';
|
|
8
6
|
|
|
9
7
|
const {stringLiteral} = types;
|
|
10
8
|
const {compare, remove} = operator;
|
|
@@ -13,9 +11,9 @@ const isPush = (path) => path.get('value').isIdentifier({
|
|
|
13
11
|
name: 'push',
|
|
14
12
|
});
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export const report = () => 'Includer should be used instead of Traverser';
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
export const match = () => ({
|
|
19
17
|
'module.exports.traverse = __a': (vars, path) => {
|
|
20
18
|
const __aPath = path.get('right.body');
|
|
21
19
|
|
|
@@ -33,7 +31,7 @@ module.exports.match = () => ({
|
|
|
33
31
|
},
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
export const replace = () => ({
|
|
37
35
|
'module.exports.traverse = __a': (vars, path) => {
|
|
38
36
|
const node = template.ast.fresh('module.exports.include = () => []');
|
|
39
37
|
const __aPath = path.get('right.body');
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
4
3
|
const {contains, traverse} = operator;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export const report = () => 'Replacer should be used instead of Traverser (https://git.io/JqcMn)';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export const match = () => ({
|
|
9
8
|
'module.exports.traverse = (__args) => __a': ({__args}, path) => {
|
|
10
9
|
const program = path.scope.getProgramParent().path;
|
|
11
10
|
|
|
@@ -29,7 +28,7 @@ module.exports.match = () => ({
|
|
|
29
28
|
},
|
|
30
29
|
});
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
export const replace = () => ({
|
|
33
32
|
'module.exports.traverse = (__args) => __a': 'module.exports.replace = (__args) => __a',
|
|
34
33
|
});
|
|
35
34
|
|