@putout/plugin-putout 8.5.1 → 8.6.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 +25 -0
- package/lib/convert-dirname-to-url/index.js +17 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,7 @@ npm i @putout/plugin-putout -D
|
|
|
31
31
|
"putout/convert-process-to-find": "on",
|
|
32
32
|
"putout/convert-method-to-property": "on",
|
|
33
33
|
"putout/convert-add-argument-to-add-args": "on",
|
|
34
|
+
"putout/convert-dirname-to-url": "on",
|
|
34
35
|
"putout/shorten-imports": "on",
|
|
35
36
|
"putout/check-replace-code": "on",
|
|
36
37
|
"putout/declare": "on",
|
|
@@ -396,6 +397,30 @@ module.exports = addArgs({
|
|
|
396
397
|
});
|
|
397
398
|
```
|
|
398
399
|
|
|
400
|
+
## convert-dirname-to-url
|
|
401
|
+
|
|
402
|
+
```js
|
|
403
|
+
import {createTest} from '@putout/test';
|
|
404
|
+
import plugin from '@putout/plugin-debugger';
|
|
405
|
+
import {createSimport} from 'simport';
|
|
406
|
+
const {__dirname} = createSimport(import.meta.url);
|
|
407
|
+
|
|
408
|
+
const test = createTest(__dirname, {
|
|
409
|
+
'remove-debugger': plugin,
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### ✅ Correct code Example
|
|
414
|
+
|
|
415
|
+
```js
|
|
416
|
+
import {createTest} from '@putout/test';
|
|
417
|
+
import plugin from '@putout/plugin-debugger';
|
|
418
|
+
|
|
419
|
+
const test = createTest(import.meta.url, {
|
|
420
|
+
'remove-debugger': plugin,
|
|
421
|
+
});
|
|
422
|
+
```
|
|
423
|
+
|
|
399
424
|
## move-require-on-top-level
|
|
400
425
|
|
|
401
426
|
### ❌ 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
|
+
|
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ module.exports.rules = {
|
|
|
20
20
|
...getRule('convert-process-to-find'),
|
|
21
21
|
...getRule('convert-method-to-property'),
|
|
22
22
|
...getRule('convert-add-argument-to-add-args'),
|
|
23
|
+
...getRule('convert-dirname-to-url'),
|
|
23
24
|
...getRule('rename-operate-to-operator'),
|
|
24
25
|
...getRule('replace-operate-with-operator'),
|
|
25
26
|
...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.6.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",
|