fix(linter): react/exhaustive-deps update span for unknown deps diagnostic (#7249)

Relates to #7246
This commit is contained in:
camc314 2024-11-12 11:55:50 +00:00
parent 3dcac1ae0b
commit 62b6327879
2 changed files with 7 additions and 8 deletions

View file

@ -226,7 +226,7 @@ impl Rule for ExhaustiveDeps {
Argument::SpreadElement(_) => {
ctx.diagnostic(unknown_dependencies_diagnostic(
hook_name.as_str(),
callback_node.span(),
call_expr.callee.span(),
));
None
}
@ -312,7 +312,7 @@ impl Rule for ExhaustiveDeps {
_ => {
ctx.diagnostic(unknown_dependencies_diagnostic(
hook_name.as_str(),
callback_node.span(),
call_expr.callee.span(),
));
None
}

View file

@ -1953,12 +1953,11 @@ source: crates/oxc_linter/src/tester.rs
help: Either include it or remove the dependency array.
⚠ react_hooks(exhaustive-deps): React Hook useEffect received a function whose dependencies are unknown.
╭─[exhaustive_deps.tsx:3:21]
2 │ const local = {};
3 │ ╭─▶ useEffect(debounce(() => {
4 │ │ console.log(local);
5 │ ╰─▶ }, delay), []);
6 │ }
╭─[exhaustive_deps.tsx:3:11]
2 │ const local = {};
3 │ useEffect(debounce(() => {
· ─────────
4 │ console.log(local);
╰────
help: Pass an inline function instead.