Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
i.declaration.declarations = i.declaration.declarations.filter((d: any) => {
if (d.id.type === AST_NODE_TYPES.ObjectPattern) {
// MUTATION!
// eslint-disable-next-line no-param-reassign
d.id.properties = d.id.properties.filter(
(p: any) =>
p.type === AST_NODE_TYPES.Property &&
p.value.type === AST_NODE_TYPES.Identifier &&
allowed.includes(p.value.name)
);
return !!d.id.properties.length;
}
if (d.id.type === AST_NODE_TYPES.Identifier) {
return allowed.includes(d.id.name);
}
return false;
}, []);
str += this.codeFromMetaProperty(ast);
break;
case AST_NODE_TYPES.MethodDefinition:
str += this.codeFromMethodDefinition(ast);
break;
case AST_NODE_TYPES.NewExpression:
str += this.codeFromNewExpression(ast);
break;
case AST_NODE_TYPES.ObjectExpression:
str += this.codeFromObjectExpression(ast);
break;
case AST_NODE_TYPES.ObjectPattern:
str += this.codeFromObjectPattern(ast);
break;
case AST_NODE_TYPES.Program:
str += this.codeFromProgram(ast);
break;
case AST_NODE_TYPES.Property:
str += this.codeFromProperty(ast);
break;
case AST_NODE_TYPES.RestElement:
str += this.codeFromRestElement(ast);
break;
case AST_NODE_TYPES.ReturnStatement: