@putout/plugin-putout 8.6.0 → 8.9.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
@@ -16,6 +16,7 @@ npm i @putout/plugin-putout -D
16
16
  ```json
17
17
  {
18
18
  "rules": {
19
+ "putout/apply-create-test": "on",
19
20
  "putout/apply-processors-destructuring": "on",
20
21
  "putout/apply-async-formatter": "on",
21
22
  "putout/add-args": "on",
@@ -32,9 +33,11 @@ npm i @putout/plugin-putout -D
32
33
  "putout/convert-method-to-property": "on",
33
34
  "putout/convert-add-argument-to-add-args": "on",
34
35
  "putout/convert-dirname-to-url": "on",
36
+ "putout/convert-url-to-dirname": "on",
35
37
  "putout/shorten-imports": "on",
36
38
  "putout/check-replace-code": "on",
37
39
  "putout/declare": "on",
40
+ "putout/includer": "on",
38
41
  "putout/move-require-on-top-level": "on"
39
42
  }
40
43
  }
@@ -78,6 +81,25 @@ test('formatter: codeframea', async ({format}) => {
78
81
  });
79
82
  ```
80
83
 
84
+ ## apply-create-test
85
+
86
+ ### ❌ Incorrect code example
87
+
88
+ ```js
89
+ const test = require('@putout/test')({
90
+ 'remove-debugger': plugin,
91
+ });
92
+ ```
93
+
94
+ ### ✅ Correct code example
95
+
96
+ ```js
97
+ const {createTest} = require('@putout/test');
98
+ const test = createTest({
99
+ 'remove-debugger': plugin,
100
+ });
101
+ ```
102
+
81
103
  ## convert-putout-test-to-create-test"
82
104
 
83
105
  Fixes results of [@putout/convert-commonjs-to-esm](https://github.com/coderaiser/putout/tree/master/packages/plugin-convert-commonjs-to-esm) work.
@@ -421,6 +443,28 @@ const test = createTest(import.meta.url, {
421
443
  });
422
444
  ```
423
445
 
446
+ ## convert-url-to-dirname-
447
+
448
+ ```js
449
+ const {createTest} = require('@putout/test');
450
+ const plugin = require('@putout/plugin-debugger');
451
+
452
+ const test = createTest(import.meta.url, {
453
+ 'remove-debugger': plugin,
454
+ });
455
+ ```
456
+
457
+ ### ✅ Correct code Example
458
+
459
+ ```js
460
+ const {createTest} = require('@putout/test');
461
+ const plugin = require('@putout/plugin-debugger');
462
+
463
+ const test = createTest(import.meta.url, {
464
+ 'remove-debugger': plugin,
465
+ });
466
+ ```
467
+
424
468
  ## move-require-on-top-level
425
469
 
426
470
  ### ❌ Incorrect code example
@@ -454,6 +498,34 @@ test('remove debugger: report', (t) => {
454
498
  });
455
499
  ```
456
500
 
501
+ ## includer
502
+
503
+ ### ❌ Incorrect code example
504
+
505
+ ```js
506
+ module.exports.include = () => 'cons __a = __b';
507
+ module.exports.exclude = () => 'var __a = __b';
508
+
509
+ module.exports.include = 'cons __a = __b';
510
+ module.exports.exclude = 'var __a = __b';
511
+
512
+ module.exports.include = ['cons __a = __b'];
513
+ module.exports.exclude = ['var __a = __b'];
514
+ ```
515
+
516
+ ### ✅ Correct code Example
517
+
518
+ ```js
519
+ module.exports.include = () => ['cons __a = __b'];
520
+ module.exports.exclude = () => ['var __a = __b'];
521
+
522
+ module.exports.include = () => ['cons __a = __b'];
523
+ module.exports.exclude = () => ['var __a = __b'];
524
+
525
+ module.exports.include = () => ['cons __a = __b'];
526
+ module.exports.exclude = () => ['var __a = __b'];
527
+ ```
528
+
457
529
  ## License
458
530
 
459
531
  MIT
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => `Apply 'createTest'`;
4
+
5
+ module.exports.replace = () => ({
6
+ 'require("@putout/test")(__dirname, __a)': `createTest(__dirname, __a)`,
7
+ });
8
+
@@ -43,6 +43,8 @@ module.exports.fix = ({path, calleePath, property, object, program, isInserted})
43
43
 
44
44
  isInserted(true);
45
45
  insertAfter(pathToInsertAfter, replaceWithAST);
46
+
47
+ path.scope.getProgramParent().crawl();
46
48
  return;
47
49
  }
48
50
 
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ const {operator} = require('putout');
4
+ const {isESM} = operator;
5
+
6
+ module.exports.report = () => `Use 'createTest(__dirname)' instead of 'createTest(import.meta.url)' in CommonJS'`;
7
+
8
+ module.exports.match = () => ({
9
+ 'createTest(import.meta.url, __a)': (vars, path) => !isESM(path),
10
+ });
11
+
12
+ module.exports.replace = () => ({
13
+ 'createTest(import.meta.url, __a)': 'createTest(__dirname, __a)',
14
+ });
15
+
@@ -4,7 +4,8 @@ const types = require('./types');
4
4
  const operator = require('./operator');
5
5
 
6
6
  module.exports = {
7
- template: `const {template} = require('putout')`,
7
+ template: `import {template} from 'putout'`,
8
+ createTest: `import {createTest} from '@putout/test'`,
8
9
  ...operator,
9
10
  ...types,
10
11
  };
@@ -9,5 +9,6 @@ module.exports = {
9
9
  isSimpleRegExp: `const {isSimpleRegExp} = operator`,
10
10
  getTemplateValues: `const {getTemplateValues} = operator`,
11
11
  addArgument: `const {addArgument} = operator`,
12
+ replaceWith: `const {replaceWith} = opreator`,
12
13
  };
13
14
 
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => 'Includer functions should return array (https://git.io/Jyndl)';
4
+
5
+ module.exports.replace = () => ({
6
+ 'module.exports.include = () => "__a"': 'module.exports.include = ["__a"]',
7
+ 'module.exports.exclude = () => "__a"': 'module.exports.exclude = ["__a"]',
8
+
9
+ 'module.exports.include = ["__a"]': 'module.exports.include = () => ["__a"]',
10
+ 'module.exports.exclude = ["__a"]': 'module.exports.exclude = () => ["__a"]',
11
+
12
+ 'module.exports.include = "__a"': 'module.exports.include = ["__a"]',
13
+ 'module.exports.exclude = "__a"': 'module.exports.exclude= ["__a"]',
14
+ });
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@ const getRule = (a) => ({
7
7
  module.exports.rules = {
8
8
  ...getRule('apply-processors-destructuring'),
9
9
  ...getRule('apply-async-formatter'),
10
+ ...getRule('apply-create-test'),
10
11
  ...getRule('convert-putout-test-to-create-test'),
11
12
  ...getRule('convert-to-no-transform-code'),
12
13
  ...getRule('convert-find-to-traverse'),
@@ -21,6 +22,7 @@ module.exports.rules = {
21
22
  ...getRule('convert-method-to-property'),
22
23
  ...getRule('convert-add-argument-to-add-args'),
23
24
  ...getRule('convert-dirname-to-url'),
25
+ ...getRule('convert-url-to-dirname'),
24
26
  ...getRule('rename-operate-to-operator'),
25
27
  ...getRule('replace-operate-with-operator'),
26
28
  ...getRule('shorten-imports'),
@@ -28,5 +30,6 @@ module.exports.rules = {
28
30
  ...getRule('declare'),
29
31
  ...getRule('add-args'),
30
32
  ...getRule('move-require-on-top-level'),
33
+ ...getRule('includer'),
31
34
  };
32
35
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "8.6.0",
3
+ "version": "8.9.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "putout plugin helps with plugins development",
6
- "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout",
6
+ "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout#readme",
7
7
  "main": "lib/index.js",
8
8
  "release": false,
9
9
  "tag": false,
@@ -42,6 +42,7 @@
42
42
  "eslint-plugin-putout": "^12.0.0",
43
43
  "lerna": "^4.0.0",
44
44
  "madrun": "^8.0.1",
45
+ "montag": "^1.2.1",
45
46
  "nodemon": "^2.0.1"
46
47
  },
47
48
  "peerDependencies": {