Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Don't do this for Program nodes - they have no parents
if (parents.length) {
// if current node is function declaration, add it to the list
var current = controller.current();
if (current.type === "FunctionDeclaration" || current.type === "FunctionExpression") {
parents.push(current);
}
// Ascend the current node's parents
for (var i = parents.length - 1; i >= 0; --i) {
// The first node that requires a scope is the node that will be
// our current node's innermost scope.
if (escope.Scope.isScopeRequired(parents[i])) {
innerBlock = parents[i];
break;
}
}
// Find and return the innermost scope
selectedScopeIndex = scopeMap[innerBlock.range[0]];
// Named function expressions create two nested scope objects. The
// outer scope contains only the function expression name. We return
// the inner scope.
if (innerBlock.type === "FunctionExpression" && innerBlock.id && innerBlock.id.name) {
++selectedScopeIndex;
}
return currentScopes[selectedScopeIndex];