Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
condition: node => {
const left = node.left;
// super[prop] = value
if (left.type === Syntax.MemberExpression && left.object.type === Syntax.Super)
return false;
if (node.operator === '=' && left.type === Syntax.MemberExpression && left.computed)
return left.property.type === Syntax.Literal ? shouldInstrumentProperty(left.property.value) : true;
return false;
},
condition: node => {
// super.prop = value
if (node.left.type === Syntax.MemberExpression && node.left.object.type === Syntax.Super)
return false;
return node.operator === '=' &&
node.left.type === Syntax.MemberExpression && !node.left.computed &&
node.left.property.type === Syntax.Identifier &&
shouldInstrumentProperty(node.left.property.name);
},
condition: (node, parent) => {
if (!node.computed)
return false;
if (node.property.type === Syntax.Literal && !shouldInstrumentProperty(node.property.value))
return false;
// super[prop]
if (node.object.type === Syntax.Super)
return false;
// object[prop] = value
if (parent.type === Syntax.AssignmentExpression && parent.left === node)
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)
condition: (node, parent) => {
if (node.computed)
return false;
if (!shouldInstrumentProperty(node.property.name))
return false;
// Skip: super.prop
if (node.object.type === Syntax.Super)
return false;
// Skip: object.prop = value
if (parent.type === Syntax.AssignmentExpression && parent.left === node)
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 === '--')