Skip to content

Commit

Permalink
refactor: optimize a little further
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Nov 4, 2022
1 parent d6a1130 commit 3431af2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/rules/utils/parseJestFnCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ export const scopeHasLocalReference = (
scope: TSESLint.Scope.Scope,
referenceName: string,
) => {
let unresolved = false;
let currentScope: TSESLint.Scope.Scope | null = scope;

while (currentScope !== null) {
Expand All @@ -609,14 +608,14 @@ export const scopeHasLocalReference = (
}
}

if (!unresolved) {
for (const ref of currentScope.through) {
unresolved = ref.identifier.name !== referenceName;
}
if (
currentScope.through.every(ref => ref.identifier.name !== referenceName)
) {
return true;
}

currentScope = currentScope.upper;
}

return unresolved;
return false;
};

0 comments on commit 3431af2

Please sign in to comment.