Skip to content

Commit

Permalink
fix(linter): update reporting spans for exhaustive-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 authored and Boshen committed Dec 4, 2024
1 parent 543df6e commit bd639fe
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 175 deletions.
13 changes: 8 additions & 5 deletions crates/oxc_linter/src/rules/react/exhaustive_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,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 @@ -324,7 +324,7 @@ impl Rule for ExhaustiveDeps {
_ => {
ctx.diagnostic(unknown_dependencies_diagnostic(
hook_name.as_str(),
callback_node.span(),
call_expr.callee.span(),
));
None
}
Expand Down Expand Up @@ -528,7 +528,7 @@ impl Rule for ExhaustiveDeps {
ctx.diagnostic(unnecessary_dependency_diagnostic(
hook_name,
&b.to_string(),
b.span,
dependencies_node.span,
));
}
});
Expand All @@ -541,7 +541,7 @@ impl Rule for ExhaustiveDeps {
ctx.diagnostic(unnecessary_dependency_diagnostic(
hook_name,
&dep.to_string(),
dep.span,
dependencies_node.span,
));
}
}
Expand All @@ -550,7 +550,10 @@ impl Rule for ExhaustiveDeps {
let Some(symbol_id) = dep.symbol_id else { continue };

if dep.chain.is_empty() && is_symbol_declaration_referentially_unique(symbol_id, ctx) {
ctx.diagnostic(dependency_changes_on_every_render_diagnostic(hook_name, dep.span));
ctx.diagnostic(dependency_changes_on_every_render_diagnostic(
hook_name,
dependencies_node.span,
));
}
}
}
Expand Down
Loading

0 comments on commit bd639fe

Please sign in to comment.