UNPKG

eslint-plugin-unicorn

Version:
20 lines (15 loc) • 414 B
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, };