@putout/plugin-putout 8.0.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
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,7 @@ npm i @putout/plugin-putout -D
|
|
|
19
17
|
{
|
|
20
18
|
"rules": {
|
|
21
19
|
"putout/apply-processors-destructuring": "on",
|
|
20
|
+
"putout/apply-async-formatter": "on",
|
|
22
21
|
"putout/add-args": "on",
|
|
23
22
|
"putout/convert-to-no-transform-code": "on",
|
|
24
23
|
"putout/convert-replace-with": "on",
|
|
@@ -57,6 +56,25 @@ test('', async ({process}) => {
|
|
|
57
56
|
});
|
|
58
57
|
```
|
|
59
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
|
+
|
|
60
78
|
## convert-to-no-transform-code
|
|
61
79
|
|
|
62
80
|
### ❌ Incorrect code example
|
|
@@ -154,7 +172,6 @@ module.exports.replace = () => ({
|
|
|
154
172
|
'const __a = __b': ({}) => {
|
|
155
173
|
},
|
|
156
174
|
'const __c = __d': ({}, path) => {
|
|
157
|
-
|
|
158
175
|
},
|
|
159
176
|
});
|
|
160
177
|
```
|
|
@@ -352,7 +369,6 @@ module.exports = addArgs({
|
|
|
352
369
|
});
|
|
353
370
|
```
|
|
354
371
|
|
|
355
|
-
|
|
356
372
|
## License
|
|
357
373
|
|
|
358
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
|
+
|
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'),
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "8.
|
|
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,11 +33,11 @@
|
|
|
33
33
|
"putout"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@putout/test": "^
|
|
36
|
+
"@putout/test": "^4.0.0",
|
|
37
37
|
"c8": "^7.5.0",
|
|
38
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"
|