@putout/plugin-putout 11.11.0 → 11.13.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.
@@ -3,8 +3,16 @@
3
3
  module.exports.report = () => `Use 'isNumericLiteral()' instead of 'isNumberLiteral()'`;
4
4
 
5
5
  module.exports.fix = (path) => {
6
- path.scope.rename('isNumberLiteral', 'isNumericLiteral');
7
- path.scope.rename('NumberLiteral', 'NumericLiteral');
6
+ const bindings = path.scope.getAllBindings();
7
+ const {name} = path.node.callee;
8
+
9
+ if (!bindings.isNumericLiteral)
10
+ path.scope.rename('isNumberLiteral', 'isNumericLiteral');
11
+
12
+ if (!bindings.NumericLiteral)
13
+ path.scope.rename('NumberLiteral', 'NumericLiteral');
14
+
15
+ path.node.callee.name = name.replace('Number', 'Numeric');
8
16
  };
9
17
 
10
18
  module.exports.traverse = ({push}) => ({
@@ -18,7 +18,7 @@ module.exports.match = () => ({
18
18
  if (withFix)
19
19
  return false;
20
20
 
21
- if (hasPushCall(path))
21
+ if (check(path))
22
22
  return false;
23
23
 
24
24
  if (!__args.length)
@@ -39,16 +39,29 @@ module.exports.replace = () => ({
39
39
  'module.exports.traverse = (__args) => __a': 'module.exports.replace = (__args) => __a',
40
40
  });
41
41
 
42
- function hasPushCall(path) {
43
- let is = false;
42
+ function check(path) {
43
+ let hasPushCall = false;
44
+ let hasTraverseMethod = false;
44
45
 
45
46
  traverse(path, {
47
+ 'ObjectMethod|ObjectProperty': (path) => {
48
+ const keyPath = path.get('key');
49
+
50
+ if (!path.parentPath.isObjectExpression())
51
+ return;
52
+
53
+ if (!keyPath.isIdentifier())
54
+ return;
55
+
56
+ hasTraverseMethod = true;
57
+ path.stop();
58
+ },
46
59
  'push(__a)': (path) => {
47
- is = true;
60
+ hasPushCall = true;
48
61
  path.stop();
49
62
  },
50
63
  });
51
64
 
52
- return is;
65
+ return hasPushCall || hasTraverseMethod;
53
66
  }
54
67
 
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "11.11.0",
3
+ "version": "11.13.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",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout#readme",
8
8
  "main": "lib/index.js",
9
+ "commitType": "colon",
9
10
  "release": false,
10
11
  "tag": false,
11
12
  "changelog": false,
@@ -39,8 +40,8 @@
39
40
  "@putout/test": "^5.0.0",
40
41
  "c8": "^7.5.0",
41
42
  "eslint": "^8.0.1",
42
- "eslint-plugin-node": "^11.0.0",
43
- "eslint-plugin-putout": "^15.0.0",
43
+ "eslint-plugin-n": "^15.2.4",
44
+ "eslint-plugin-putout": "^16.0.0",
44
45
  "lerna": "^5.0.0",
45
46
  "madrun": "^9.0.0",
46
47
  "montag": "^1.2.1",