@putout/plugin-putout 14.3.0 → 14.4.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 +6 -3
- package/lib/apply-namaspace-specifier/index.js +33 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -712,7 +712,7 @@ const test = createTest(import.meta.url, {
|
|
|
712
712
|
});
|
|
713
713
|
```
|
|
714
714
|
|
|
715
|
-
## convert-url-to-dirname
|
|
715
|
+
## convert-url-to-dirname
|
|
716
716
|
|
|
717
717
|
### ❌ Example of incorrect code
|
|
718
718
|
|
|
@@ -752,6 +752,10 @@ module.exports.report = () => `'report' should be a 'function'`;
|
|
|
752
752
|
|
|
753
753
|
## convert-get-rule-to-require
|
|
754
754
|
|
|
755
|
+
- ✅ import [Nested plugins](https://github.com/coderaiser/putout/tree/master/packages/engine-loader#nested-plugin) in [**Deno** and **Browser**](https://github.com/putoutjs/bundle/);
|
|
756
|
+
- ✅ easier bundle with rollup without [`dynamicRequireTargets`](https://github.com/rollup/plugins/tree/master/packages/commonjs/#dynamicrequiretargets);
|
|
757
|
+
- ✅ easier to migrate to **ESM**;
|
|
758
|
+
|
|
755
759
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/38336fcc5b5ae6e441697e098067319c/dd98578c9554b7bd5dceee0499118f7d8216e1da).
|
|
756
760
|
|
|
757
761
|
### ❌ Example of incorrect code
|
|
@@ -799,10 +803,9 @@ const test = require('@putout/test')(__dirname, {
|
|
|
799
803
|
});
|
|
800
804
|
|
|
801
805
|
test('remove debugger: report', (t) => {
|
|
802
|
-
|
|
806
|
+
t.transform('debugger', {
|
|
803
807
|
'remove-debugger': removeDebugger,
|
|
804
808
|
});
|
|
805
|
-
|
|
806
809
|
t.end();
|
|
807
810
|
});
|
|
808
811
|
```
|
|
@@ -6,7 +6,31 @@ module.exports.fix = ({first}) => {
|
|
|
6
6
|
first.node.type = 'ImportNamespaceSpecifier';
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
module.exports.traverse = ({push}) => ({
|
|
9
|
+
module.exports.traverse = ({push, listStore}) => ({
|
|
10
|
+
'export const rules = __object': listStore,
|
|
11
|
+
...createImportVisitor({
|
|
12
|
+
push,
|
|
13
|
+
names: [
|
|
14
|
+
'./index.js',
|
|
15
|
+
'../lib/index.js',
|
|
16
|
+
],
|
|
17
|
+
}),
|
|
18
|
+
'Program': {
|
|
19
|
+
exit(path) {
|
|
20
|
+
const rules = listStore();
|
|
21
|
+
|
|
22
|
+
if (!rules.length)
|
|
23
|
+
return;
|
|
24
|
+
|
|
25
|
+
path.traverse(createImportVisitor({
|
|
26
|
+
push,
|
|
27
|
+
names: ['any'],
|
|
28
|
+
}));
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const createImportVisitor = ({push, names}) => ({
|
|
10
34
|
ImportDeclaration(path) {
|
|
11
35
|
const {value} = path.node.source;
|
|
12
36
|
const first = path.get('specifiers.0');
|
|
@@ -17,20 +41,14 @@ module.exports.traverse = ({push}) => ({
|
|
|
17
41
|
if (first.isImportNamespaceSpecifier())
|
|
18
42
|
return;
|
|
19
43
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (value === '../lib/index.js') {
|
|
29
|
-
push({
|
|
30
|
-
path,
|
|
31
|
-
first,
|
|
32
|
-
});
|
|
33
|
-
return;
|
|
44
|
+
for (const name of names) {
|
|
45
|
+
if (value === name || name === 'any') {
|
|
46
|
+
push({
|
|
47
|
+
path,
|
|
48
|
+
first,
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
34
52
|
}
|
|
35
53
|
},
|
|
36
54
|
});
|
package/package.json
CHANGED