@putout/plugin-putout 26.5.0 → 26.6.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.
@@ -7,31 +7,16 @@ const {
7
7
  isIdentifier,
8
8
  } = types;
9
9
 
10
- const getNewName = (name) => {
11
- if (name.startsWith('TS')) {
12
- const other = name.slice(2);
13
- return `ts${other}`;
14
- }
15
-
16
- if (name.startsWith('JSX')) {
17
- const other = name.slice(3);
18
- return `jsx${other}`;
19
- }
20
-
21
- const [first] = name;
22
- const other = name.slice(1);
23
-
24
- return first.toLowerCase() + other;
25
- };
26
-
27
10
  export const report = () => `Use lowercased node builders`;
28
11
 
29
12
  export const fix = (path) => {
30
13
  const {name} = path.node;
31
-
32
14
  const newName = getNewName(name);
15
+ const bindings = path.scope.getAllBindings();
16
+
17
+ if (!bindings[newName])
18
+ rename(path, name, newName);
33
19
 
34
- rename(path, name, newName);
35
20
  path.node.name = newName;
36
21
  };
37
22
 
@@ -60,3 +45,20 @@ export const traverse = ({push}) => ({
60
45
  push(path);
61
46
  },
62
47
  });
48
+
49
+ const getNewName = (name) => {
50
+ if (name.startsWith('TS')) {
51
+ const other = name.slice(2);
52
+ return `ts${other}`;
53
+ }
54
+
55
+ if (name.startsWith('JSX')) {
56
+ const other = name.slice(3);
57
+ return `jsx${other}`;
58
+ }
59
+
60
+ const [first] = name;
61
+ const other = name.slice(1);
62
+
63
+ return first.toLowerCase() + other;
64
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "26.5.0",
3
+ "version": "26.6.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",