@putout/plugin-putout 8.6.0 → 8.7.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,6 +33,7 @@ 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",
@@ -78,6 +80,25 @@ test('formatter: codeframea', async ({format}) => {
78
80
  });
79
81
  ```
80
82
 
83
+ ## apply-create-test
84
+
85
+ ### ❌ Incorrect code example
86
+
87
+ ```js
88
+ const test = require('@putout/test')({
89
+ 'remove-debugger': plugin,
90
+ });
91
+ ```
92
+
93
+ ### ✅ Correct code example
94
+
95
+ ```js
96
+ const {createTest} = require('@putout/test');
97
+ const test = createTest({
98
+ 'remove-debugger': plugin,
99
+ });
100
+ ```
101
+
81
102
  ## convert-putout-test-to-create-test"
82
103
 
83
104
  Fixes results of [@putout/convert-commonjs-to-esm](https://github.com/coderaiser/putout/tree/master/packages/plugin-convert-commonjs-to-esm) work.
@@ -421,6 +442,28 @@ const test = createTest(import.meta.url, {
421
442
  });
422
443
  ```
423
444
 
445
+ ## convert-url-to-dirname-
446
+
447
+ ```js
448
+ const {createTest} = require('@putout/test');
449
+ const plugin = require('@putout/plugin-debugger');
450
+
451
+ const test = createTest(import.meta.url, {
452
+ 'remove-debugger': plugin,
453
+ });
454
+ ```
455
+
456
+ ### ✅ Correct code Example
457
+
458
+ ```js
459
+ const {createTest} = require('@putout/test');
460
+ const plugin = require('@putout/plugin-debugger');
461
+
462
+ const test = createTest(import.meta.url, {
463
+ 'remove-debugger': plugin,
464
+ });
465
+ ```
466
+
424
467
  ## move-require-on-top-level
425
468
 
426
469
  ### ❌ Incorrect code example
@@ -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
+
@@ -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
  };
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'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "8.6.0",
3
+ "version": "8.7.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "putout plugin helps with plugins development",
6
6
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout",