• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

coderaiser / putout / 6184622411

14 Sep 2023 11:12AM CUT coverage: 100.0%. Remained the same
6184622411

push

github

coderaiser
chore: @putout/plugin-remove-unused-variables: v7.0.0

7637 of 7637 branches covered (100.0%)

Branch coverage included in aggregate %.

30343 of 30343 relevant lines covered (100.0%)

14684.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/codemods/convert-pascal-to-camel/lib/pascal-to-camel.js
1
export const report = (path) => {
3✔
2
    return `Should be used camelCase instead of PascalCase in functions ${path.node.name}`;
36✔
3
};
3✔
4

3✔
5
export const fix = (path) => {
3✔
6
    const {name} = path.node;
30✔
7
    const camel = toCamel(name);
30✔
8
    
30✔
9
    path.node.name = camel;
30✔
10
    path.scope.rename(name, toCamel(name));
30✔
11
};
3✔
12

3✔
13
export const traverse = ({push}) => ({
3✔
14
    ClassProperty: checkBig('key', push),
18✔
15
    ClassMethod: checkBig('key', push),
18✔
16
    FunctionDeclaration: checkBig('id', push),
18✔
17
    
18✔
18
    FunctionExpression(path) {
18✔
19
        const idPath = path.get('id');
24✔
20
        
24✔
21
        if (!isBig(idPath))
24✔
22
            return;
24✔
23
        
6✔
24
        push(idPath);
6✔
25
    },
18✔
26
    
18✔
27
    VariableDeclarator(path) {
18✔
28
        let isJSX = false;
42✔
29
        const idPath = path.get('id');
42✔
30
        const initPath = path.get('init');
42✔
31
        
42✔
32
        if (!isBig(idPath))
42✔
33
            return;
42✔
34
        
21✔
35
        path.traverse({
21✔
36
            JSXElement(path) {
21✔
37
                isJSX = true;
3✔
38
                path.stop();
3✔
39
            },
21✔
40
        });
21✔
41
        
21✔
42
        if (isJSX)
21✔
43
            return;
42✔
44
        
18✔
45
        if (initPath.isArrowFunctionExpression())
18✔
46
            return push(idPath);
42✔
47
        
12✔
48
        if (initPath.isFunctionExpression())
12✔
49
            return push(idPath);
42✔
50
    },
18✔
51
});
3✔
52

3✔
53
function toCamel(name) {
60✔
54
    const newName = name.slice(1);
60✔
55
    const [a] = name;
60✔
56
    const b = a.toLowerCase();
60✔
57
    
60✔
58
    return `${b}${newName}`;
60✔
59
}
60✔
60

3✔
61
function isBig({node}) {
93✔
62
    if (!node)
93✔
63
        return false;
93✔
64
    
87✔
65
    if (!node.name)
87✔
66
        return false;
93✔
67
    
84✔
68
    return /[A-Z]/.test(node.name[0]);
84✔
69
}
93✔
70

3✔
71
function checkBig(query, push) {
54✔
72
    return (path) => {
54✔
73
        const keyPath = path.get(query);
27✔
74
        
27✔
75
        if (!isBig(keyPath))
27✔
76
            return;
27✔
77
        
15✔
78
        push(keyPath);
15✔
79
    };
54✔
80
}
54✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc