@putout/plugin-putout 14.3.0 → 14.5.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
@@ -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
- const test = require('@putout/test')(__dirname, {
806
+ t.transform('debugger', {
803
807
  'remove-debugger': removeDebugger,
804
808
  });
805
-
806
809
  t.end();
807
810
  });
808
811
  ```
@@ -6,7 +6,32 @@ 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
+ 'import {createTest} from "@putout/test"': listStore,
12
+ ...createImportVisitor({
13
+ push,
14
+ names: [
15
+ './index.js',
16
+ '../lib/index.js',
17
+ ],
18
+ }),
19
+ 'Program': {
20
+ exit(path) {
21
+ const rules = listStore();
22
+
23
+ if (!rules.length)
24
+ return;
25
+
26
+ path.traverse(createImportVisitor({
27
+ push,
28
+ names: ['any'],
29
+ }));
30
+ },
31
+ },
32
+ });
33
+
34
+ const createImportVisitor = ({push, names}) => ({
10
35
  ImportDeclaration(path) {
11
36
  const {value} = path.node.source;
12
37
  const first = path.get('specifiers.0');
@@ -17,20 +42,17 @@ module.exports.traverse = ({push}) => ({
17
42
  if (first.isImportNamespaceSpecifier())
18
43
  return;
19
44
 
20
- if (value === './index.js') {
21
- push({
22
- path,
23
- first,
24
- });
45
+ if (first.isImportSpecifier())
25
46
  return;
26
- }
27
47
 
28
- if (value === '../lib/index.js') {
29
- push({
30
- path,
31
- first,
32
- });
33
- return;
48
+ for (const name of names) {
49
+ if (value === name || name === 'any') {
50
+ push({
51
+ path,
52
+ first,
53
+ });
54
+ return;
55
+ }
34
56
  }
35
57
  },
36
58
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "14.3.0",
3
+ "version": "14.5.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",