@putout/plugin-putout 20.9.0 → 20.9.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.
@@ -1,6 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const {parse, print, transform} = require('putout');
3
+ const {
4
+ parse,
5
+ print,
6
+ transform,
7
+ } = require('putout');
4
8
  const tryCatch = require('try-catch');
5
9
  const pluginGenerate = require('./plugin-generate');
6
10
 
@@ -11,21 +15,20 @@ module.exports = (rootPath, source) => {
11
15
 
12
16
  if (parseError)
13
17
  return [parseError];
14
-
18
+
15
19
  const getVar = createVarStore(rootPath);
16
20
 
17
- transform(ast, source, {
21
+ transform(ast, source, {
18
22
  rules: {
19
- 'generate': ['on', {
23
+ generate: ['on', {
20
24
  getVar,
21
25
  }],
22
26
  },
23
27
  plugins: [
24
28
  ['generate', pluginGenerate],
25
- ]
29
+ ],
26
30
  });
27
31
 
28
-
29
32
  const code = print(ast);
30
33
 
31
34
  return [null, code];
@@ -33,13 +36,13 @@ module.exports = (rootPath, source) => {
33
36
 
34
37
  function createVarStore(path) {
35
38
  const store = {};
36
-
39
+
37
40
  return (name) => {
38
41
  if (store[name])
39
42
  return store[name];
40
-
43
+
41
44
  store[name] = path.scope.generateUid();
42
-
45
+
43
46
  return store[name];
44
47
  };
45
48
  }
@@ -8,6 +8,7 @@ const {
8
8
  ArrayPattern,
9
9
  ObjectExpression,
10
10
  } = types;
11
+
11
12
  const {replaceWith} = operator;
12
13
  const noop = () => {};
13
14
 
@@ -1,10 +1,15 @@
1
1
  'use strict';
2
2
 
3
- const putout = require('putout');
3
+ const {
4
+ operator,
5
+ parse,
6
+ print,
7
+ transform,
8
+ } = require('putout');
4
9
  const tryCatch = require('try-catch');
5
10
  const generateCode = require('./generate-code');
6
11
  const noop = () => {};
7
- const {operator} = putout;
12
+
8
13
  const {
9
14
  compare,
10
15
  extract,
@@ -88,10 +93,11 @@ const createTraverseReplacer = (push) => (path) => {
88
93
  return;
89
94
  }
90
95
 
91
- const [transformError, result] = tryCatch(putout, keyCode, {
92
- printer: 'putout',
93
- fix: true,
96
+ const ast = parse(keyCode, {
94
97
  isTS: true,
98
+ });
99
+
100
+ const [transformError] = tryCatch(transform, ast, keyCode, {
95
101
  plugins: [
96
102
  ['evaluate', {
97
103
  report: noop,
@@ -112,7 +118,7 @@ const createTraverseReplacer = (push) => (path) => {
112
118
  return;
113
119
  }
114
120
 
115
- const code = result.code.slice(0, -1);
121
+ const code = print(ast).slice(0, -1);
116
122
  const [error, is] = tryCatch(compare, rmSemi(code), template);
117
123
 
118
124
  if (error || !is)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "20.9.0",
3
+ "version": "20.9.1",
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",