Skip to content

Commit

Permalink
fix(linter): react/exhaustive-deps update span for unknown deps diagn…
Browse files Browse the repository at this point in the history
…ostic (#7249)

Relates to #7246
  • Loading branch information
camc314 committed Nov 12, 2024
1 parent 3dcac1a commit 62b6327
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/react_hooks/exhaustive_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
11 changes: 5 additions & 6 deletions crates/oxc_linter/src/snapshots/exhaustive_deps.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
3useEffect(debounce(() => {
· ─────────
4console.log(local);
╰────
help: Pass an inline function instead.
Expand Down

0 comments on commit 62b6327

Please sign in to comment.