@putout/plugin-putout 7.11.0 → 8.2.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 +61 -7
- package/lib/add-args/index.js +10 -0
- package/lib/apply-async-formatter/index.js +47 -0
- package/lib/convert-add-argument-to-add-args/index.js +13 -0
- package/lib/convert-destructuring-to-identifier/index.js +1 -0
- package/lib/convert-putout-test-to-create-test/index.js +11 -0
- package/lib/declare/operator.js +1 -0
- package/lib/index.js +4 -1
- package/package.json +6 -6
- package/lib/add-missing-argument/index.js +0 -30
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
# @putout/plugin-putout [![NPM version][NPMIMGURL]][NPMURL]
|
|
1
|
+
# @putout/plugin-putout [![NPM version][NPMIMGURL]][NPMURL]
|
|
2
2
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-putout.svg?style=flat&longCache=true
|
|
4
4
|
[NPMURL]: https://npmjs.org/package/@putout/plugin-putout"npm"
|
|
5
|
-
[DependencyStatusURL]: https://david-dm.org/coderaiser/putout?path=packages/plugin-putout
|
|
6
|
-
[DependencyStatusIMGURL]: https://david-dm.org/coderaiser/putout.svg?path=packages/plugin-putout
|
|
7
5
|
|
|
8
|
-
`putout
|
|
6
|
+
🐊[`Putout`](https://github.com/coderaiser/putout) plugin helps with 🐊[`Putout`](https://github.com/coderaiser/putout) plugins development.
|
|
9
7
|
|
|
10
8
|
## Install
|
|
11
9
|
|
|
@@ -19,7 +17,9 @@ npm i @putout/plugin-putout -D
|
|
|
19
17
|
{
|
|
20
18
|
"rules": {
|
|
21
19
|
"putout/apply-processors-destructuring": "on",
|
|
22
|
-
"putout/
|
|
20
|
+
"putout/apply-async-formatter": "on",
|
|
21
|
+
"putout/add-args": "on",
|
|
22
|
+
"putout/convert-putout-test-to-create-test": "on",
|
|
23
23
|
"putout/convert-to-no-transform-code": "on",
|
|
24
24
|
"putout/convert-replace-with": "on",
|
|
25
25
|
"putout/convert-replace-with-multiple": "on",
|
|
@@ -30,6 +30,7 @@ npm i @putout/plugin-putout -D
|
|
|
30
30
|
"putout/convert-traverse-to-replace": "on",
|
|
31
31
|
"putout/convert-process-to-find": "on",
|
|
32
32
|
"putout/convert-method-to-property": "on",
|
|
33
|
+
"putout/convert-add-argument-to-add-args": "on",
|
|
33
34
|
"putout/shorten-imports": "on",
|
|
34
35
|
"putout/check-replace-code": "on",
|
|
35
36
|
"putout/declare": "on"
|
|
@@ -56,6 +57,38 @@ test('', async ({process}) => {
|
|
|
56
57
|
});
|
|
57
58
|
```
|
|
58
59
|
|
|
60
|
+
## apply-async-formatter
|
|
61
|
+
|
|
62
|
+
### ❌ Incorrect code example
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
test('formatter: codeframea', (t) => {
|
|
66
|
+
t.format(codeframe, 1);
|
|
67
|
+
t.end();
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### ✅ Correct code example
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
test('formatter: codeframea', async ({format}) => {
|
|
75
|
+
await format(codeframe, 1);
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
## convert-putout-test-to-create-test"
|
|
79
|
+
|
|
80
|
+
### ❌ Incorrect code example
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
import putoutTest from '@putout/test';
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### ✅ Correct code Example
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import createTest from '@putout/test';
|
|
90
|
+
```
|
|
91
|
+
|
|
59
92
|
## convert-to-no-transform-code
|
|
60
93
|
|
|
61
94
|
### ❌ Incorrect code example
|
|
@@ -153,7 +186,6 @@ module.exports.replace = () => ({
|
|
|
153
186
|
'const __a = __b': ({}) => {
|
|
154
187
|
},
|
|
155
188
|
'const __c = __d': ({}, path) => {
|
|
156
|
-
|
|
157
189
|
},
|
|
158
190
|
});
|
|
159
191
|
```
|
|
@@ -311,7 +343,7 @@ compare(a, 'const __a = __b');
|
|
|
311
343
|
isIdentifier(a);
|
|
312
344
|
```
|
|
313
345
|
|
|
314
|
-
## add-
|
|
346
|
+
## add-args
|
|
315
347
|
|
|
316
348
|
### ❌ Incorrect code example
|
|
317
349
|
|
|
@@ -329,6 +361,28 @@ test('', ({comparePlaces}) => {
|
|
|
329
361
|
});
|
|
330
362
|
```
|
|
331
363
|
|
|
364
|
+
## convert-add-argument-to-add-args
|
|
365
|
+
|
|
366
|
+
```js
|
|
367
|
+
const {operator} = require('putout');
|
|
368
|
+
const {addArgument} = operator;
|
|
369
|
+
|
|
370
|
+
module.exports = addArgument({
|
|
371
|
+
t: ['t', 'test("__a", (__args) => __body)'],
|
|
372
|
+
});
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### ✅ Correct code Example
|
|
376
|
+
|
|
377
|
+
```js
|
|
378
|
+
const {operator} = require('putout');
|
|
379
|
+
const {addArgs} = operator;
|
|
380
|
+
|
|
381
|
+
module.exports = addArgs({
|
|
382
|
+
t: ['t', 'test("__a", (__args) => __body)'],
|
|
383
|
+
});
|
|
384
|
+
```
|
|
385
|
+
|
|
332
386
|
## License
|
|
333
387
|
|
|
334
388
|
MIT
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
operator,
|
|
5
|
+
types,
|
|
6
|
+
} = require('putout');
|
|
7
|
+
|
|
8
|
+
const computed = true;
|
|
9
|
+
const shorthand = true;
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
Identifier,
|
|
13
|
+
ObjectPattern,
|
|
14
|
+
ObjectProperty,
|
|
15
|
+
} = types;
|
|
16
|
+
|
|
17
|
+
const {compare} = operator;
|
|
18
|
+
|
|
19
|
+
module.exports.report = () => 'Use Async API to test Formatter';
|
|
20
|
+
|
|
21
|
+
module.exports.replace = () => ({
|
|
22
|
+
't.format(__args)': create('format'),
|
|
23
|
+
't.noFormat(__args)': create('noFormat'),
|
|
24
|
+
't.formatMany(__args)': create('formatMany'),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const create = (name) => (vars, path) => {
|
|
28
|
+
const {block} = path.scope;
|
|
29
|
+
const {body} = block.body;
|
|
30
|
+
const n = body.length - 1;
|
|
31
|
+
const nameId = Identifier(name);
|
|
32
|
+
|
|
33
|
+
block.async = true;
|
|
34
|
+
|
|
35
|
+
block.params = [
|
|
36
|
+
ObjectPattern([
|
|
37
|
+
ObjectProperty(nameId, nameId, !computed, shorthand),
|
|
38
|
+
]),
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
if (compare(body[n], 't.end()')) {
|
|
42
|
+
body.pop();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return `await ${name}(__args)`;
|
|
46
|
+
};
|
|
47
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.report = () => 'Use addArgs instead of addArgument';
|
|
4
|
+
|
|
5
|
+
module.exports.replace = () => ({
|
|
6
|
+
'addArgument(__args)': (vars, path) => {
|
|
7
|
+
path.scope.rename('addArgument', 'addArgs');
|
|
8
|
+
path.scope.crawl();
|
|
9
|
+
|
|
10
|
+
return path;
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.report = () => `Use 'createTest' instead of 'putoutTest'`;
|
|
4
|
+
|
|
5
|
+
module.exports.replace = () => ({
|
|
6
|
+
'import putoutTest from "@putout/test"': (vars, path) => {
|
|
7
|
+
path.scope.rename('putoutTest', 'createTest');
|
|
8
|
+
return path;
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
|
package/lib/declare/operator.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -6,6 +6,8 @@ const getRule = (a) => ({
|
|
|
6
6
|
|
|
7
7
|
module.exports.rules = {
|
|
8
8
|
...getRule('apply-processors-destructuring'),
|
|
9
|
+
...getRule('apply-async-formatter'),
|
|
10
|
+
...getRule('convert-putout-test-to-create-test'),
|
|
9
11
|
...getRule('convert-to-no-transform-code'),
|
|
10
12
|
...getRule('convert-find-to-traverse'),
|
|
11
13
|
...getRule('convert-replace-with'),
|
|
@@ -17,11 +19,12 @@ module.exports.rules = {
|
|
|
17
19
|
...getRule('convert-traverse-to-replace'),
|
|
18
20
|
...getRule('convert-process-to-find'),
|
|
19
21
|
...getRule('convert-method-to-property'),
|
|
22
|
+
...getRule('convert-add-argument-to-add-args'),
|
|
20
23
|
...getRule('rename-operate-to-operator'),
|
|
21
24
|
...getRule('replace-operate-with-operator'),
|
|
22
25
|
...getRule('shorten-imports'),
|
|
23
26
|
...getRule('check-replace-code'),
|
|
24
27
|
...getRule('declare'),
|
|
25
|
-
...getRule('add-
|
|
28
|
+
...getRule('add-args'),
|
|
26
29
|
};
|
|
27
30
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
5
|
"description": "putout plugin helps with plugins development",
|
|
6
|
-
"homepage": "
|
|
6
|
+
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"release": false,
|
|
9
9
|
"tag": false,
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"putout"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@putout/test": "^
|
|
36
|
+
"@putout/test": "^4.0.0",
|
|
37
37
|
"c8": "^7.5.0",
|
|
38
|
-
"eslint": "^8.0.
|
|
38
|
+
"eslint": "^8.0.1",
|
|
39
39
|
"eslint-plugin-node": "^11.0.0",
|
|
40
|
-
"eslint-plugin-putout": "^
|
|
40
|
+
"eslint-plugin-putout": "^12.0.0",
|
|
41
41
|
"lerna": "^4.0.0",
|
|
42
42
|
"madrun": "^8.0.1",
|
|
43
43
|
"nodemon": "^2.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"putout": ">=20.
|
|
46
|
+
"putout": ">=20.13"
|
|
47
47
|
},
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"engines": {
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {types} = require('putout');
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
Identifier,
|
|
7
|
-
ObjectPattern,
|
|
8
|
-
ObjectProperty,
|
|
9
|
-
} = types;
|
|
10
|
-
|
|
11
|
-
module.exports.report = () => 'Argument "comparePlaces" is missing';
|
|
12
|
-
|
|
13
|
-
module.exports.fix = (path) => {
|
|
14
|
-
const id = Identifier('comparePlaces');
|
|
15
|
-
path.scope.block.params = [
|
|
16
|
-
ObjectPattern([ObjectProperty(id, id)]),
|
|
17
|
-
];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
module.exports.traverse = ({push}) => ({
|
|
21
|
-
ReferencedIdentifier(path) {
|
|
22
|
-
if (path.node.name !== 'comparePlaces')
|
|
23
|
-
return;
|
|
24
|
-
|
|
25
|
-
if (path.scope.hasBinding('comparePlaces'))
|
|
26
|
-
return;
|
|
27
|
-
|
|
28
|
-
push(path);
|
|
29
|
-
},
|
|
30
|
-
});
|