@putout/plugin-putout 7.12.0 → 8.2.1
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 +74 -8
- package/lib/{add-missing-argument → add-args}/index.js +2 -2
- 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 +14 -0
- package/lib/index.js +4 -1
- package/package.json +7 -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` 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,49 @@ 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
|
+
|
|
79
|
+
## convert-putout-test-to-create-test"
|
|
80
|
+
|
|
81
|
+
Fixes results of [@putout/convert-commonjs-to-esm](https://github.com/coderaiser/putout/tree/master/packages/plugin-convert-commonjs-to-esm) work.
|
|
82
|
+
|
|
83
|
+
### ❌ Incorrect code example
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
import putoutTest from '@putout/test';
|
|
87
|
+
|
|
88
|
+
const test = putoutTest(__dirname, {
|
|
89
|
+
'remove-unused-variables': rmVars,
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### ✅ Correct code Example
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
import createTest from '@putout/test';
|
|
97
|
+
|
|
98
|
+
const test = createTest(__dirname, {
|
|
99
|
+
'remove-unused-variables': rmVars,
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
59
103
|
## convert-to-no-transform-code
|
|
60
104
|
|
|
61
105
|
### ❌ Incorrect code example
|
|
@@ -153,7 +197,6 @@ module.exports.replace = () => ({
|
|
|
153
197
|
'const __a = __b': ({}) => {
|
|
154
198
|
},
|
|
155
199
|
'const __c = __d': ({}, path) => {
|
|
156
|
-
|
|
157
200
|
},
|
|
158
201
|
});
|
|
159
202
|
```
|
|
@@ -286,7 +329,8 @@ module.exports.replace = () => ({
|
|
|
286
329
|
});
|
|
287
330
|
```
|
|
288
331
|
|
|
289
|
-
There is no `fix` for this rule, it used internally to be more confident about `test coverage`, because of declaration form, transforms cannon be checked by `nyc` and `c8`, and uncovered lines can find unfixable false possitives when running on code.
|
|
332
|
+
There is no `fix` for this rule, it used internally to be more confident about `test coverage`, because of declaration form, transforms cannon be checked by `nyc` and `c8`, and uncovered lines can find unfixable false possitives when running on code.
|
|
333
|
+
This is additional tests, if you forget to test some case (from a big list of rules that is supported) it will be checked with this `rule` and make transforms more stable.
|
|
290
334
|
|
|
291
335
|
## declare
|
|
292
336
|
|
|
@@ -311,7 +355,7 @@ compare(a, 'const __a = __b');
|
|
|
311
355
|
isIdentifier(a);
|
|
312
356
|
```
|
|
313
357
|
|
|
314
|
-
## add-
|
|
358
|
+
## add-args
|
|
315
359
|
|
|
316
360
|
### ❌ Incorrect code example
|
|
317
361
|
|
|
@@ -329,6 +373,28 @@ test('', ({comparePlaces}) => {
|
|
|
329
373
|
});
|
|
330
374
|
```
|
|
331
375
|
|
|
376
|
+
## convert-add-argument-to-add-args
|
|
377
|
+
|
|
378
|
+
```js
|
|
379
|
+
const {operator} = require('putout');
|
|
380
|
+
const {addArgument} = operator;
|
|
381
|
+
|
|
382
|
+
module.exports = addArgument({
|
|
383
|
+
t: ['t', 'test("__a", (__args) => __body)'],
|
|
384
|
+
});
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### ✅ Correct code Example
|
|
388
|
+
|
|
389
|
+
```js
|
|
390
|
+
const {operator} = require('putout');
|
|
391
|
+
const {addArgs} = operator;
|
|
392
|
+
|
|
393
|
+
module.exports = addArgs({
|
|
394
|
+
t: ['t', 'test("__a", (__args) => __body)'],
|
|
395
|
+
});
|
|
396
|
+
```
|
|
397
|
+
|
|
332
398
|
## License
|
|
333
399
|
|
|
334
400
|
MIT
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {operator} = require('putout');
|
|
4
|
-
const {
|
|
4
|
+
const {addArgs} = operator;
|
|
5
5
|
|
|
6
|
-
module.exports =
|
|
6
|
+
module.exports = addArgs({
|
|
7
7
|
comparePlaces: ['{comparePlaces}', 'test("__a", (__args) => __body)'],
|
|
8
8
|
compare: ['{compare}', 'test("__a", (__args) => __body)'],
|
|
9
9
|
});
|
|
@@ -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,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.report = () => `Use 'createTest' instead of 'putoutTest'`;
|
|
4
|
+
|
|
5
|
+
module.exports.filter = ({scope}) => !scope.bindings.createTest;
|
|
6
|
+
|
|
7
|
+
module.exports.include = () => [
|
|
8
|
+
'import putoutTest from "@putout/test"',
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
module.exports.fix = (path) => {
|
|
12
|
+
path.scope.rename('putoutTest', 'createTest');
|
|
13
|
+
};
|
|
14
|
+
|
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.1",
|
|
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,
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"url": "git://github.com/coderaiser/putout.git"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
+
"wisdom": "madrun wisdom",
|
|
16
17
|
"test": "madrun test",
|
|
17
18
|
"watch:test": "madrun watch:test",
|
|
18
19
|
"lint": "madrun lint",
|
|
@@ -33,17 +34,17 @@
|
|
|
33
34
|
"putout"
|
|
34
35
|
],
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@putout/test": "^
|
|
37
|
+
"@putout/test": "^4.0.0",
|
|
37
38
|
"c8": "^7.5.0",
|
|
38
|
-
"eslint": "^8.0.
|
|
39
|
+
"eslint": "^8.0.1",
|
|
39
40
|
"eslint-plugin-node": "^11.0.0",
|
|
40
|
-
"eslint-plugin-putout": "^
|
|
41
|
+
"eslint-plugin-putout": "^12.0.0",
|
|
41
42
|
"lerna": "^4.0.0",
|
|
42
43
|
"madrun": "^8.0.1",
|
|
43
44
|
"nodemon": "^2.0.1"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
|
-
"putout": ">=20.
|
|
47
|
+
"putout": ">=20.13"
|
|
47
48
|
},
|
|
48
49
|
"license": "MIT",
|
|
49
50
|
"engines": {
|