@putout/plugin-putout 12.2.0 → 12.3.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
@@ -78,8 +78,7 @@ It helps to preserve comments.
78
78
  ### ❌ Example of incorrect code
79
79
 
80
80
  ```js
81
- export
82
- const fix = (path) => {
81
+ export const fix = (path) => {
83
82
  path.remove();
84
83
  };
85
84
  ```
@@ -80,10 +80,7 @@ module.exports = (rootPath, key) => {
80
80
  ],
81
81
  });
82
82
 
83
- return [
84
- transformError,
85
- result?.code,
86
- ];
83
+ return [transformError, result?.code];
87
84
  };
88
85
 
89
86
  function createVarStore(path) {
@@ -119,15 +119,11 @@ function parseKey(propertyPath) {
119
119
  Error(`Replace key cannot be computed: '${keyPath.toString()}'`),
120
120
  ];
121
121
 
122
- return [
123
- null,
124
- key,
125
- ];
122
+ return [null, key];
126
123
  }
127
124
 
128
125
  function hasMatch(path) {
129
- const {body} = path.scope
130
- .getProgramParent().path.node;
126
+ const {body} = path.scope.getProgramParent().path.node;
131
127
 
132
128
  for (const current of body) {
133
129
  if (compare(current, 'module.exports.match = __a'))
@@ -17,17 +17,20 @@ module.exports.report = () => {
17
17
 
18
18
  function isRequire(path) {
19
19
  return path
20
- .get('callee').isIdentifier({
20
+ .get('callee')
21
+ .isIdentifier({
21
22
  name: 'require',
22
23
  });
23
24
  }
24
25
 
25
26
  function isBabelTypes(path) {
26
27
  return path
27
- .get('arguments.0').isStringLiteral({
28
+ .get('arguments.0')
29
+ .isStringLiteral({
28
30
  value: '@babel/types',
29
31
  });
30
32
  }
33
+
31
34
  module.exports.traverse = ({push}) => ({
32
35
  CallExpression(path) {
33
36
  if (!isRequire(path))
@@ -73,9 +73,7 @@ function getTraverseCall(path) {
73
73
 
74
74
  path.traverse({
75
75
  CallExpression(path) {
76
- if (!path.get('callee').isIdentifier({
77
- name: 'traverse',
78
- }))
76
+ if (!path.get('callee').isIdentifier({name: 'traverse'}))
79
77
  return;
80
78
 
81
79
  result = path;
@@ -64,6 +64,7 @@ function getVarPath(bindings) {
64
64
 
65
65
  return insertAfter.path;
66
66
  }
67
+
67
68
  module.exports.traverse = ({push}) => {
68
69
  const isInserted = fullstore();
69
70
 
@@ -54,6 +54,7 @@ function getVarPath(bindings) {
54
54
 
55
55
  return insertAfter.path;
56
56
  }
57
+
57
58
  module.exports.traverse = ({push}) => ({
58
59
  CallExpression(path) {
59
60
  const calleePath = path.get('callee');
@@ -10,7 +10,8 @@ const {StringLiteral} = types;
10
10
  const {compare} = operator;
11
11
 
12
12
  const isPush = (path) => path
13
- .get('value').isIdentifier({
13
+ .get('value')
14
+ .isIdentifier({
14
15
  name: 'push',
15
16
  });
16
17
 
@@ -12,9 +12,7 @@ module.exports.match = () => ({
12
12
  'module.exports.traverse = (__args) => __a': ({__args}, path) => {
13
13
  const program = path.scope.getProgramParent().path;
14
14
 
15
- const withFix = contains(program, [
16
- 'module.exports.fix = __a',
17
- ]);
15
+ const withFix = contains(program, ['module.exports.fix = __a']);
18
16
 
19
17
  if (withFix)
20
18
  return false;
@@ -25,9 +23,7 @@ module.exports.match = () => ({
25
23
  if (!__args.length)
26
24
  return true;
27
25
 
28
- const withPush = contains(__args[0], [
29
- 'push',
30
- ]);
26
+ const withPush = contains(__args[0], ['push']);
31
27
 
32
28
  if (withPush)
33
29
  return false;
@@ -61,8 +61,7 @@ module.exports.replace = () => ({
61
61
  const buildRequire = template(`const NAME = REQUIRE`);
62
62
 
63
63
  function declareRequire({__a, __b}, path) {
64
- const shortName = __a.value || __a.name
65
- .split('/').pop();
64
+ const shortName = __a.value || __a.name.split('/').pop();
66
65
 
67
66
  const name = justCamelCase(shortName);
68
67
 
@@ -74,8 +73,7 @@ function declareRequire({__a, __b}, path) {
74
73
  if (path.scope.hasBinding(name))
75
74
  return name;
76
75
 
77
- const programPath = path.scope
78
- .getProgramParent().path;
76
+ const programPath = path.scope.getProgramParent().path;
79
77
 
80
78
  programPath.node.body.unshift(requireNode);
81
79
 
@@ -10,6 +10,7 @@ module.exports.report = ({correct, operatorPath}) => {
10
10
 
11
11
  module.exports.fix = ({path, incorrect, correct}) => {
12
12
  path.node.value = path.node.value.replace(incorrect, correct);
13
+ path.node.raw = path.node.raw.replace(incorrect, correct);
13
14
  };
14
15
 
15
16
  module.exports.traverse = ({push}) => ({
@@ -72,8 +73,5 @@ function isCorrect({path, incorrect}) {
72
73
  const {value} = messagePath.node;
73
74
  const is = !incorrect.test(value);
74
75
 
75
- return [
76
- is,
77
- messagePath,
78
- ];
76
+ return [is, messagePath];
79
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "12.2.0",
3
+ "version": "12.3.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",