@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 CHANGED
@@ -1,11 +1,9 @@
1
- # @putout/plugin-putout [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL]
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` plugin helps with `putout` plugins development.
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,10 @@
1
+ 'use strict';
2
+
3
+ const {operator} = require('putout');
4
+ const {addArgs} = operator;
5
+
6
+ module.exports = addArgs({
7
+ comparePlaces: ['{comparePlaces}', 'test("__a", (__args) => __body)'],
8
+ compare: ['{compare}', 'test("__a", (__args) => __body)'],
9
+ });
10
+
@@ -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
+
@@ -26,5 +26,6 @@ function findUp(path, str) {
26
26
 
27
27
  path = path.parentPath;
28
28
  }
29
+
29
30
  return false;
30
31
  }
@@ -8,5 +8,6 @@ module.exports = {
8
8
  declare: `const {declare} = operator`,
9
9
  isSimpleRegExp: `const {isSimpleRegExp} = operator`,
10
10
  getTemplateValues: `const {getTemplateValues} = operator`,
11
+ addArgument: `const {addArgument} = operator`,
11
12
  };
12
13
 
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": "7.10.0",
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": "http://github.com/coderaiser/putout",
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": "^3.0.0",
36
+ "@putout/test": "^4.0.0",
37
37
  "c8": "^7.5.0",
38
- "eslint": "^8.0.0-beta.0",
38
+ "eslint": "^8.0.1",
39
39
  "eslint-plugin-node": "^11.0.0",
40
- "eslint-plugin-putout": "^10.0.0",
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.7"
46
+ "putout": ">=20.13"
47
47
  },
48
48
  "license": "MIT",
49
49
  "engines": {