@putout/plugin-putout 25.8.0 → 25.9.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
@@ -682,7 +682,7 @@ module.exports.scan = (path, {push, trackFile}) => {
682
682
 
683
683
  ## create-test
684
684
 
685
- Add properties to `createTest` options, here is exmample of `.putout.json`:
685
+ Add properties to `createTest` options, here is example of `.putout.json`:
686
686
 
687
687
  ```json
688
688
  {
@@ -1,33 +1,33 @@
1
- import {types} from 'putout';
1
+ import {types, operator} from 'putout';
2
2
 
3
- const {isIdentifier} = types;
3
+ const {rename} = operator;
4
4
 
5
- export const report = () => `Use lowercased node builders`;
6
-
7
- export const fix = (path) => {
8
- const {name} = path.node;
9
-
5
+ const getNewName = (name) => {
10
6
  if (name.startsWith('TS')) {
11
7
  const other = name.slice(2);
12
-
13
- path.node.name = `ts${other}`;
14
- return;
8
+ return `ts${other}`;
15
9
  }
16
10
 
17
11
  const [first] = name;
18
12
  const other = name.slice(1);
19
13
 
20
- path.node.name = first.toLowerCase() + other;
14
+ return first.toLowerCase() + other;
15
+ };
16
+
17
+ export const report = () => `Use lowercased node builders`;
18
+
19
+ export const fix = (path) => {
20
+ const {name} = path.node;
21
+
22
+ const newName = getNewName(name);
23
+
24
+ rename(path, name, newName);
25
+ path.node.name = newName;
21
26
  };
22
27
 
23
28
  export const traverse = ({push}) => ({
24
- CallExpression(path) {
25
- const calleePath = path.get('callee');
26
-
27
- if (!isIdentifier(calleePath))
28
- return;
29
-
30
- const {name} = calleePath.node;
29
+ ReferencedIdentifier(path) {
30
+ const {name} = path.node;
31
31
  const [first, second] = name;
32
32
 
33
33
  if (!/[A-Z]/.test(first))
@@ -39,6 +39,6 @@ export const traverse = ({push}) => ({
39
39
  if (!types[name])
40
40
  return;
41
41
 
42
- push(calleePath);
42
+ push(path);
43
43
  },
44
44
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "25.8.0",
3
+ "version": "25.9.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",