Skip to content

Commit

Permalink
refactor(linter): jest/valid-title fixer to use Span::shrink meth…
Browse files Browse the repository at this point in the history
…od (#6703)

Used shrink apis from span
  • Loading branch information
tapanprakasht authored Oct 20, 2024
1 parent 902a3d0 commit 29c1447
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/oxc_linter/src/rules/jest/valid_title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ fn validate_title(
if !valid_title.ignore_space && trimmed_title != title {
let (error, help) = Message::AccidentalSpace.detail();
ctx.diagnostic_with_fix(valid_title_diagnostic(error, help, span), |fixer| {
let target_span = Span::new(span.start + 1, span.end - 1);
fixer.replace(target_span, trimmed_title.to_string())
fixer.replace(span.shrink(1), trimmed_title.to_string())
});
}

Expand All @@ -316,7 +315,7 @@ fn validate_title(
let (error, help) = Message::DuplicatePrefix.detail();
ctx.diagnostic_with_fix(valid_title_diagnostic(error, help, span), |fixer| {
let replaced_title = title[first_word.len()..].trim().to_string();
fixer.replace(span.shrink_left(1).shrink_right(1), replaced_title)
fixer.replace(span.shrink(1), replaced_title)
});
return;
}
Expand Down

0 comments on commit 29c1447

Please sign in to comment.