Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isNamedObject(node, objectPath, length) {
// console.log("checking for named object ", node, objectPath, length);
while ( length > 1
&& node.type === Syntax.MemberExpression
&& isIdentifier(node.property, objectPath[length-1]) ) {
node = node.object;
length--;
}
return length === 1 && isIdentifier(node, objectPath[0]);
}
currentContext.varList.push(getIdentifierName(node.id));
}
// @ts-ignore
currentContext.varList = currentContext.varList.concat(getParamsName(node.params));
}
}
else if (type === Syntax.VariableDeclarator) {
currentContext.varList = currentContext.varList.concat(getVariableDeclaratorName(node));
} else if (type === Syntax.Identifier) {
// todo check 是否在 context stack
// @ts-ignore
if (inContextStack(contextStack, node.name)) {
return;
}
// a.b b return
if (parent.type === Syntax.MemberExpression && parent.object !== node) {
return;
}
const name = getIdentifierName(node);
if (unVarList.indexOf(name) === -1) {
unVarList.push(name);
}
}
},
leave(node) {
visitMemberExpression.test = function(node, path, state) {
return node.type === Syntax.MemberExpression &&
node.property.type === Syntax.Identifier &&
reservedDict[node.property.name] === true;
};