@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
|
|
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 {
|
|
3
|
+
const {rename} = operator;
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
25
|
-
const
|
|
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(
|
|
42
|
+
push(path);
|
|
43
43
|
},
|
|
44
44
|
});
|
package/package.json
CHANGED