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, parent) => {
if (node.name !== 'postMessage' || !parent)
return false;
// Skip: window.postMessage, postMessage.call
if (parent.type === Syntax.MemberExpression)
return false;
// Skip: class X { postMessage () {} }
if (parent.type === Syntax.MethodDefinition)
return false;
// Skip: class postMessage { x () {} }
if (parent.type === Syntax.ClassDeclaration)
return false;
// Skip: function postMessage () { ... }
if ((parent.type === Syntax.FunctionExpression || parent.type === Syntax.FunctionDeclaration) &&
parent.id === node)
return false;
// Skip: function (postMessage) { ... } || function func(postMessage) { ... } || postMessage => { ... }
if ((parent.type === Syntax.FunctionExpression || parent.type === Syntax.FunctionDeclaration ||
parent.type === Syntax.ArrowFunctionExpression) && parent.params.indexOf(node) !== -1)
return false;
// Skip: { postMessage: value }
if (parent.type === Syntax.Property && parent.key === node)
return false;
// Skip: function (location) { ... } || function func(location) { ... } || location => { ... }
if ((parent.type === Syntax.FunctionExpression || parent.type === Syntax.FunctionDeclaration ||
parent.type === Syntax.ArrowFunctionExpression) && parent.params.indexOf(node) !== -1)
return false;
// Skip already transformed: __get$Loc(location)
if (parent.type === Syntax.CallExpression && parent.callee.type === Syntax.Identifier &&
parent.callee.name === INSTRUCTION.getLocation)
return false;
// Skip: class X { location () {} }
if (parent.type === Syntax.MethodDefinition)
return false;
// Skip: class location { x () {} }
if (parent.type === Syntax.ClassDeclaration)
return false;
// Skip: function x (...location) {}
if (parent.type === Syntax.RestElement)
return false;
return true;
},
condition: (node, parent) => {
if (node.name === 'eval' && parent) {
// Skip: eval()
if (parent.type === Syntax.CallExpression && parent.callee === node)
return false;
// Skip: class X { eval () {} }
if (parent.type === Syntax.MethodDefinition)
return false;
// Skip: class eval { x () {} }
if (parent.type === Syntax.ClassDeclaration)
return false;
// Skip: window.eval, eval.call
if (parent.type === Syntax.MemberExpression)
return false;
// Skip: function eval () { ... }
if ((parent.type === Syntax.FunctionExpression || parent.type === Syntax.FunctionDeclaration) &&
parent.id === node)
return false;
// Skip: function (eval) { ... } || function func(eval) { ... } || eval => { ... }
if ((parent.type === Syntax.FunctionExpression || parent.type === Syntax.FunctionDeclaration ||
parent.type === Syntax.ArrowFunctionExpression) && parent.params.indexOf(node) !== -1)
return false;