@putout/plugin-putout 7.10.0 → 8.1.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 +64 -5
- 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/declare/operator.js +1 -0
- package/lib/index.js +3 -0
- package/package.json +6 -6
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,6 +17,8 @@ npm i @putout/plugin-putout -D
|
|
|
19
17
|
{
|
|
20
18
|
"rules": {
|
|
21
19
|
"putout/apply-processors-destructuring": "on",
|
|
20
|
+
"putout/apply-async-formatter": "on",
|
|
21
|
+
"putout/add-args": "on",
|
|
22
22
|
"putout/convert-to-no-transform-code": "on",
|
|
23
23
|
"putout/convert-replace-with": "on",
|
|
24
24
|
"putout/convert-replace-with-multiple": "on",
|
|
@@ -29,6 +29,7 @@ npm i @putout/plugin-putout -D
|
|
|
29
29
|
"putout/convert-traverse-to-replace": "on",
|
|
30
30
|
"putout/convert-process-to-find": "on",
|
|
31
31
|
"putout/convert-method-to-property": "on",
|
|
32
|
+
"putout/convert-add-argument-to-add-args": "on",
|
|
32
33
|
"putout/shorten-imports": "on",
|
|
33
34
|
"putout/check-replace-code": "on",
|
|
34
35
|
"putout/declare": "on"
|
|
@@ -55,6 +56,25 @@ test('', async ({process}) => {
|
|
|
55
56
|
});
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
## apply-async-formatter
|
|
60
|
+
|
|
61
|
+
### ❌ Incorrect code example
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
test('formatter: codeframea', (t) => {
|
|
65
|
+
t.format(codeframe, 1);
|
|
66
|
+
t.end();
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### ✅ Correct code example
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
test('formatter: codeframea', async ({format}) => {
|
|
74
|
+
await format(codeframe, 1);
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
58
78
|
## convert-to-no-transform-code
|
|
59
79
|
|
|
60
80
|
### ❌ Incorrect code example
|
|
@@ -152,7 +172,6 @@ module.exports.replace = () => ({
|
|
|
152
172
|
'const __a = __b': ({}) => {
|
|
153
173
|
},
|
|
154
174
|
'const __c = __d': ({}, path) => {
|
|
155
|
-
|
|
156
175
|
},
|
|
157
176
|
});
|
|
158
177
|
```
|
|
@@ -310,6 +329,46 @@ compare(a, 'const __a = __b');
|
|
|
310
329
|
isIdentifier(a);
|
|
311
330
|
```
|
|
312
331
|
|
|
332
|
+
## add-args
|
|
333
|
+
|
|
334
|
+
### ❌ Incorrect code example
|
|
335
|
+
|
|
336
|
+
```js
|
|
337
|
+
test('', () => {
|
|
338
|
+
comparePlaces();
|
|
339
|
+
});
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### ✅ Correct code Example
|
|
343
|
+
|
|
344
|
+
```js
|
|
345
|
+
test('', ({comparePlaces}) => {
|
|
346
|
+
comparePlaces();
|
|
347
|
+
});
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## convert-add-argument-to-add-args
|
|
351
|
+
|
|
352
|
+
```js
|
|
353
|
+
const {operator} = require('putout');
|
|
354
|
+
const {addArgument} = operator;
|
|
355
|
+
|
|
356
|
+
module.exports = addArgument({
|
|
357
|
+
t: ['t', 'test("__a", (__args) => __body)'],
|
|
358
|
+
});
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### ✅ Correct code Example
|
|
362
|
+
|
|
363
|
+
```js
|
|
364
|
+
const {operator} = require('putout');
|
|
365
|
+
const {addArgs} = operator;
|
|
366
|
+
|
|
367
|
+
module.exports = addArgs({
|
|
368
|
+
t: ['t', 'test("__a", (__args) => __body)'],
|
|
369
|
+
});
|
|
370
|
+
```
|
|
371
|
+
|
|
313
372
|
## License
|
|
314
373
|
|
|
315
374
|
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
|
+
|
package/lib/declare/operator.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const getRule = (a) => ({
|
|
|
6
6
|
|
|
7
7
|
module.exports.rules = {
|
|
8
8
|
...getRule('apply-processors-destructuring'),
|
|
9
|
+
...getRule('apply-async-formatter'),
|
|
9
10
|
...getRule('convert-to-no-transform-code'),
|
|
10
11
|
...getRule('convert-find-to-traverse'),
|
|
11
12
|
...getRule('convert-replace-with'),
|
|
@@ -17,10 +18,12 @@ module.exports.rules = {
|
|
|
17
18
|
...getRule('convert-traverse-to-replace'),
|
|
18
19
|
...getRule('convert-process-to-find'),
|
|
19
20
|
...getRule('convert-method-to-property'),
|
|
21
|
+
...getRule('convert-add-argument-to-add-args'),
|
|
20
22
|
...getRule('rename-operate-to-operator'),
|
|
21
23
|
...getRule('replace-operate-with-operator'),
|
|
22
24
|
...getRule('shorten-imports'),
|
|
23
25
|
...getRule('check-replace-code'),
|
|
24
26
|
...getRule('declare'),
|
|
27
|
+
...getRule('add-args'),
|
|
25
28
|
};
|
|
26
29
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.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": {
|