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

View file

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