How to use the putout.isAssignmentPattern 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
if (id) {
                declare(path, node.id.name);
                
                if (!parentPath.isBlock() && !parentPath.isProgram())
                    use(path, node.id.name);
            }
            
            for (const paramPath of paramsPaths) {
                const {node} = paramPath;
                
                if (isIdentifier(node)) {
                    declare(paramPath, node.name);
                    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,
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / traverse.js View on Github external
return (propertiesPaths) => {
        for (const path of propertiesPaths) {
            const {value} = path.node;
            
            if (isIdentifier(value)) {
                declare(path, value.name);
                continue;
            }
            
            if (isObjectPattern(value)) {
                const process = processObjectPattern({use, declare});
                process(path.get('value.properties'));
                continue;
            }
            
            if (isAssignmentPattern(value)) {
                const useAssignment = traverseAssignmentPattern({
                    use,
                });
                useAssignment(path.get('value.right'));
                
                const leftPath = path.get('value.left');
                
                if (leftPath.isIdentifier())
                    declare(path, leftPath.node.name);
                
                continue;
            }
        }
    };
};
github coderaiser / putout / packages / plugin-remove-unused-variables / lib / get-vars / get-vars.js View on Github external
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;
                        
                        declare(nodePath, propPath.node.value.name);
                    },
                });