refactor(linter): jest/valid-title fixer to use Span::shrink method (#6703)

Used shrink apis from span
This commit is contained in:
Tapan Prakash 2024-10-21 04:10:09 +05:30 committed by GitHub
parent 902a3d0495
commit 29c14474ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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())
});
}
@ -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;
}