Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// export interface Bang {}
// export type Foo = string | number;
if (
i.type === AST_NODE_TYPES.ExportNamedDeclaration &&
(i.declaration.type === AST_NODE_TYPES.TSTypeAliasDeclaration ||
i.declaration.type === AST_NODE_TYPES.FunctionDeclaration ||
i.declaration.type === AST_NODE_TYPES.TSInterfaceDeclaration)
) {
return allowed.includes(i.declaration.id.name);
}
// export const manager = {};
// export const {f,g: h} = {f: 4, g:5};
if (
i.type === AST_NODE_TYPES.ExportNamedDeclaration &&
i.declaration.type === AST_NODE_TYPES.VariableDeclaration
) {
// MUTATION!
// eslint-disable-next-line no-param-reassign
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) {
str += this.codeFromThrowStatement(ast);
break;
case AST_NODE_TYPES.TryStatement:
str += this.codeFromTryStatement(ast);
break;
case AST_NODE_TYPES.UnaryExpression:
str += this.codeFromUnaryExpression(ast);
break;
case AST_NODE_TYPES.UpdateExpression:
str += this.codeFromUpdateExpression(ast);
break;
case AST_NODE_TYPES.VariableDeclaration:
str += this.codeFromVariableDeclaration(ast);
break;
case AST_NODE_TYPES.VariableDeclarator:
str += this.codeFromVariableDeclarator(ast);
break;
case AST_NODE_TYPES.WhileStatement:
str += this.codeFromWhileStatement(ast);
break;
case AST_NODE_TYPES.WithStatement:
str += this.codeFromWithStatement(ast);
break;
case AST_NODE_TYPES.YieldExpression: