Skip to content

Commit

Permalink
refactor: condition
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjuan committed Feb 18, 2024
1 parent 5e109a1 commit 35d0a18
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/eslint-plugin/src/rules/no-use-before-define.ts
Expand Up @@ -315,13 +315,10 @@ export default createRule<Options, MessageIds>({
variable: TSESLint.Scope.Variable,
reference: TSESLint.Scope.Reference,
): boolean {
if (variable.identifiers[0].range[1] <= reference.identifier.range[1]) {
if (reference.isValueReference) {
return !isInInitializer(variable, reference);
}
return true;
}
return false;
return (
variable.identifiers[0].range[1] <= reference.identifier.range[1] &&
!(reference.isValueReference && isInInitializer(variable, reference))
);
}

/**
Expand Down

0 comments on commit 35d0a18

Please sign in to comment.