Skip to content

Commit

Permalink
fix: correct hasUnsafeRefsInNonIIFE logic
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Jan 1, 2024
1 parent 36814ac commit 0fd38e9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/rules/no-loop-func.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,17 @@ module.exports = {

// Check if there are unsafe references used within non-immediately-invoked nested functions
const hasUnsafeRefsInNonIIFE = unsafeRefs.some(r => {
let refFunctionNode = r.from.variableScope.block;
let refScope = r.from.variableScope;

if (node === refFunctionNode) {
return !isIIFE(refFunctionNode);
if (node === refScope.block) {
return !isIIFE(refScope.block);
}

while (node !== refFunctionNode) {
if (!isIIFE(refFunctionNode)) {
while (node !== refScope.block) {
if (!isIIFE(refScope.block)) {
return true;
}
refFunctionNode = refFunctionNode.parent;
refScope = refScope.upper.variableScope;
}

return false;
Expand Down

0 comments on commit 0fd38e9

Please sign in to comment.