Skip to content

Commit

Permalink
fix(linter): false positive in exhaustive-deps (#7626)
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Dec 4, 2024
1 parent 8a68ef4 commit e824501
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion crates/oxc_linter/src/rules/react/exhaustive_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,10 @@ impl Rule for ExhaustiveDeps {
})
});

if has_write_reference {
if has_write_reference
|| get_declaration_from_reference_id(ident.reference_id(), ctx.semantic())
.is_some_and(|decl| decl.scope_id() != component_scope_id)
{
continue;
}
}
Expand Down Expand Up @@ -2107,6 +2110,21 @@ fn test() {
});
}, [options]);
}",
"export function useCanvasZoomOrScroll() {
useEffect(() => {
let wheelStopTimeoutId: { current: number | undefined } = { current: undefined };
wheelStopTimeoutId = requestAnimationFrameTimeout(() => {
setLastInteraction?.(null);
}, 300);
return () => {
if (wheelStopTimeoutId.current !== undefined) {
console.log('h1');
}
};
}, []);
}",
];

let fail = vec![
Expand Down

0 comments on commit e824501

Please sign in to comment.