eslint-plugin-unicorn
Version:
More than 300 powerful ESLint rules
20 lines (15 loc) • 414 B
JavaScript
const isDefinitionBeforeReference = (definition, referenceNode, context) =>
context.sourceCode.getRange(definition.name)[0] <= context.sourceCode.getRange(referenceNode)[0];
const getVariableByName = (name, scope) => {
while (scope) {
const variable = scope.set.get(name);
if (variable) {
return variable;
}
scope = scope.upper;
}
};
export {
getVariableByName,
isDefinitionBeforeReference,
};