How to use the putout.isIdentifier function in putout

To help you get started, we’ve selected a few putout examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
continue;
                }
                
                if (isAssignmentPattern(node)) {
                    traverseAssign(paramPath);
                    continue;
                }
                
                if (isObjectPattern(node)) {
                    processObj(paramPath.get('properties'));
                    continue;
                }
            }
            
            // ArrowFunction only
            if (isIdentifier(body))
                use(path, body.name);
            
            addParams({
                path,
                params,
            });
        },
        ...jsx(use),
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
UnaryExpression(path) {
            const {argument} = path.node;
            
            if (isIdentifier(argument))
                use(path, argument.name);
        },
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
SwitchStatement(path) {
            const {node} = path;
            
            if (isIdentifier(node.discriminant))
                use(path, node.discriminant.name);
            
            for (const {test} of node.cases) {
                if (isIdentifier(test))
                    use(path, test.name);
            }
        },
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
VariableDeclarator(path) {
            const {node} = path;
            const {init} = node;
            const idPath = path.get('id');
            const isForIn = path.parentPath.parentPath.isForInStatement();
            
            if (isIdentifier(node.id)) {
                declare(path, node.id.name);
                isForIn && use(path, node.id.name);
            } else if (isObjectPattern(node.id)) {
                idPath.traverse({
                    ObjectProperty(propPath) {
                        if (isAssignmentPattern(propPath.node.value)) {
                            traverseAssign(propPath.get('value'));
                            return;
                        }
                        
                        if (!isIdentifier(propPath.node.value))
                            return;
                        
                        const {properties} = node.id;
                        const isOne = properties.length === 1;
                        const nodePath = isOne ? path : propPath;
github coderaiser / putout / packages / plugin-react-hooks / lib / convert-component-to-use-state / index.js View on Github external
VariableDeclarator(path) {
            const {id, init} = path.node;
            
            const name = 'React';
            
            if (!isObjectPattern(id) || !isIdentifier(init, {name}))
                return;
            
            const propertiesPaths = path.get('id.properties');
            
            for (const propPath of propertiesPaths) {
                const {node} = propPath;
                
                if (isIdentifier(node.key, {name: 'Component'})) {
                    places.push(propPath);
                }
            }
        },
    });
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
ExpressionStatement(path) {
            const {node} = path;
            
            if (isIdentifier(node.expression))
                use(path, node.expression.name);
        },
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
CallExpression(path) {
            const {node} = path;
            const {callee} = node;
            
            if (isIdentifier(callee))
                use(path, node.callee.name);
            
            path.traverse({
                SpreadElement(path) {
                    const {argument} = path.node;
                    
                    if (isIdentifier(argument))
                        use(path, argument.name);
                },
                Identifier(path) {
                    if (node.arguments.includes(path.node))
                        use(path, path.node.name);
                },
            });
        },
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / traverse.js View on Github external
return (path) => {
        const {node} = path;
        const {right} = node;
        
        if (isIdentifier(node))
            use(path.parentPath, node.name);
        
        if (isIdentifier(right))
            use(path, right.name);
    };
};
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
return use(path, declaration.id.name);
            }
            
            if (isVariableDeclaration(declaration)) {
                const {declarations} = declaration;
                
                for (const {id} of declarations) {
                    if (isIdentifier(id))
                        use(path, id.name);
                }
                
                return;
            }
            
            for (const {local} of specifiers) {
                if (isIdentifier(local))
                    use(path, local.name);
            }
        },
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
SwitchStatement(path) {
            const {node} = path;
            
            if (isIdentifier(node.discriminant))
                use(path, node.discriminant.name);
            
            for (const {test} of node.cases) {
                if (isIdentifier(test))
                    use(path, test.name);
            }
        },