Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return false;
// delete object[prop]
if (parent.type === Syntax.UnaryExpression && parent.operator === 'delete')
return false;
// object[prop]++ || object[prop]-- || ++object[prop] || --object[prop]
if (parent.type === Syntax.UpdateExpression && parent.operator === '++' || parent.operator === '--')
return false;
// object[prop]()
if (parent.type === Syntax.CallExpression && parent.callee === node)
return false;
// new (object[prop])() || new (object[prop])
if (parent.type === Syntax.NewExpression && parent.callee === node)
return false;
// for(object[prop] in source)
if (parent.type === Syntax.ForInStatement && parent.left === node)
return false;
return true;
},
return false;
// Skip: delete object.prop
if (parent.type === Syntax.UnaryExpression && parent.operator === 'delete')
return false;
// Skip: object.prop()
if (parent.type === Syntax.CallExpression && parent.callee === node)
return false;
// Skip: object.prop++ || object.prop-- || ++object.prop || --object.prop
if (parent.type === Syntax.UpdateExpression && parent.operator === '++' || parent.operator === '--')
return false;
// Skip: new (object.prop)() || new (object.prop)
if (parent.type === Syntax.NewExpression && parent.callee === node)
return false;
// Skip: for(object.prop in source)
if (parent.type === Syntax.ForInStatement && parent.left === node)
return false;
return true;
},
static create (currState: State, node: Node, parent?: T, key?: keyof T, hasTransformedAncestor: boolean = false): State {
const isNewExpression = node.type === Syntax.NewExpression;
const isNewExpressionAncestor = isNewExpression && !currState.newExpressionAncestor;
const newState = new State();
newState.hasTransformedAncestor = currState.hasTransformedAncestor || hasTransformedAncestor;
newState.newExpressionAncestor = isNewExpressionAncestor ? node : currState.newExpressionAncestor;
newState.newExpressionAncestorParent = isNewExpressionAncestor ? parent : currState.newExpressionAncestorParent;
// @ts-ignore
newState.newExpressionAncestorKey = isNewExpressionAncestor ? key : currState.newExpressionAncestorKey;
return newState;
}
}