-
-
Save mcloide/e5f630901e1be4b9b128 to your computer and use it in GitHub Desktop.
ESLint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findVariable(name) { | |
var scope = context.getScope(), | |
scopeVariable = []; | |
function filter(variable) { | |
return variable.name === name; | |
} | |
scopeVariable = scope.variables.filter(filter); | |
if (scopeVariable.length === 0) { | |
if (!scope.upper) { | |
return null; | |
} | |
scope = scope.upper; | |
} else { | |
for (i = 0; i < scopeVariable.length; ++i) { | |
scopeVariable = scope.variables.filter(filter); | |
if (scopeVariable.length === 0) { | |
if (!scope.upper) { | |
return null; | |
} | |
scope = scope.upper; | |
} | |
} | |
} | |
return lookupVariable(scopeVariable[0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment