@putout/plugin-putout 8.5.1 → 8.8.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 +68 -0
- package/lib/apply-create-test/index.js +8 -0
- package/lib/convert-dirname-to-url/index.js +17 -0
- package/lib/convert-replace-with/index.js +2 -0
- package/lib/convert-url-to-dirname/index.js +15 -0
- package/lib/declare/declarations.js +2 -1
- package/lib/declare/operator.js +1 -0
- package/lib/index.js +3 -0
- package/package.json +2 -1
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",
|
|
@@ -31,6 +32,8 @@ npm i @putout/plugin-putout -D
|
|
|
31
32
|
"putout/convert-process-to-find": "on",
|
|
32
33
|
"putout/convert-method-to-property": "on",
|
|
33
34
|
"putout/convert-add-argument-to-add-args": "on",
|
|
35
|
+
"putout/convert-dirname-to-url": "on",
|
|
36
|
+
"putout/convert-url-to-dirname": "on",
|
|
34
37
|
"putout/shorten-imports": "on",
|
|
35
38
|
"putout/check-replace-code": "on",
|
|
36
39
|
"putout/declare": "on",
|
|
@@ -77,6 +80,25 @@ test('formatter: codeframea', async ({format}) => {
|
|
|
77
80
|
});
|
|
78
81
|
```
|
|
79
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
|
+
|
|
80
102
|
## convert-putout-test-to-create-test"
|
|
81
103
|
|
|
82
104
|
Fixes results of [@putout/convert-commonjs-to-esm](https://github.com/coderaiser/putout/tree/master/packages/plugin-convert-commonjs-to-esm) work.
|
|
@@ -396,6 +418,52 @@ module.exports = addArgs({
|
|
|
396
418
|
});
|
|
397
419
|
```
|
|
398
420
|
|
|
421
|
+
## convert-dirname-to-url
|
|
422
|
+
|
|
423
|
+
```js
|
|
424
|
+
import {createTest} from '@putout/test';
|
|
425
|
+
import plugin from '@putout/plugin-debugger';
|
|
426
|
+
import {createSimport} from 'simport';
|
|
427
|
+
const {__dirname} = createSimport(import.meta.url);
|
|
428
|
+
|
|
429
|
+
const test = createTest(__dirname, {
|
|
430
|
+
'remove-debugger': plugin,
|
|
431
|
+
});
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### ✅ Correct code Example
|
|
435
|
+
|
|
436
|
+
```js
|
|
437
|
+
import {createTest} from '@putout/test';
|
|
438
|
+
import plugin from '@putout/plugin-debugger';
|
|
439
|
+
|
|
440
|
+
const test = createTest(import.meta.url, {
|
|
441
|
+
'remove-debugger': plugin,
|
|
442
|
+
});
|
|
443
|
+
```
|
|
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
|
+
|
|
399
467
|
## move-require-on-top-level
|
|
400
468
|
|
|
401
469
|
### ❌ Incorrect code example
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {operator} = require('putout');
|
|
4
|
+
const {isESM} = operator;
|
|
5
|
+
|
|
6
|
+
module.exports.report = () => `Use 'createTest(import.meta.url)' instead of 'createTest(__dirname)'`;
|
|
7
|
+
|
|
8
|
+
module.exports.match = () => ({
|
|
9
|
+
'createTest(__dirname, __a)': (vars, path) => {
|
|
10
|
+
return isESM(path);
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
module.exports.replace = () => ({
|
|
15
|
+
'createTest(__dirname, __a)': 'createTest(import.meta.url, __a)',
|
|
16
|
+
});
|
|
17
|
+
|
|
@@ -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: `
|
|
7
|
+
template: `import {template} from 'putout'`,
|
|
8
|
+
createTest: `import {createTest} from '@putout/test'`,
|
|
8
9
|
...operator,
|
|
9
10
|
...types,
|
|
10
11
|
};
|
package/lib/declare/operator.js
CHANGED
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'),
|
|
@@ -20,6 +21,8 @@ module.exports.rules = {
|
|
|
20
21
|
...getRule('convert-process-to-find'),
|
|
21
22
|
...getRule('convert-method-to-property'),
|
|
22
23
|
...getRule('convert-add-argument-to-add-args'),
|
|
24
|
+
...getRule('convert-dirname-to-url'),
|
|
25
|
+
...getRule('convert-url-to-dirname'),
|
|
23
26
|
...getRule('rename-operate-to-operator'),
|
|
24
27
|
...getRule('replace-operate-with-operator'),
|
|
25
28
|
...getRule('shorten-imports'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.8.1",
|
|
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",
|
|
@@ -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": {
|