Skip to content

Commit 8a68ef4

Browse files
committed
fix(linter): update reporting spans for exhaustive-deps (#7625)
1 parent 543df6e commit 8a68ef4

2 files changed

Lines changed: 177 additions & 175 deletions

File tree

crates/oxc_linter/src/rules/react/exhaustive_deps.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl Rule for ExhaustiveDeps {
238238
Argument::SpreadElement(_) => {
239239
ctx.diagnostic(unknown_dependencies_diagnostic(
240240
hook_name.as_str(),
241-
callback_node.span(),
241+
call_expr.callee.span(),
242242
));
243243
None
244244
}
@@ -324,7 +324,7 @@ impl Rule for ExhaustiveDeps {
324324
_ => {
325325
ctx.diagnostic(unknown_dependencies_diagnostic(
326326
hook_name.as_str(),
327-
callback_node.span(),
327+
call_expr.callee.span(),
328328
));
329329
None
330330
}
@@ -528,7 +528,7 @@ impl Rule for ExhaustiveDeps {
528528
ctx.diagnostic(unnecessary_dependency_diagnostic(
529529
hook_name,
530530
&b.to_string(),
531-
b.span,
531+
dependencies_node.span,
532532
));
533533
}
534534
});
@@ -541,7 +541,7 @@ impl Rule for ExhaustiveDeps {
541541
ctx.diagnostic(unnecessary_dependency_diagnostic(
542542
hook_name,
543543
&dep.to_string(),
544-
dep.span,
544+
dependencies_node.span,
545545
));
546546
}
547547
}
@@ -550,7 +550,10 @@ impl Rule for ExhaustiveDeps {
550550
let Some(symbol_id) = dep.symbol_id else { continue };
551551

552552
if dep.chain.is_empty() && is_symbol_declaration_referentially_unique(symbol_id, ctx) {
553-
ctx.diagnostic(dependency_changes_on_every_render_diagnostic(hook_name, dep.span));
553+
ctx.diagnostic(dependency_changes_on_every_render_diagnostic(
554+
hook_name,
555+
dependencies_node.span,
556+
));
554557
}
555558
}
556559
}

0 commit comments

Comments
 (0)