mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(linter): add fixer for @typescript-eslint/consistent-type-imports (#3984)
This rule's fixer is complicated, I do line by line copy as possible.
7b13dae347/packages/eslint-plugin/src/rules/consistent-type-imports.ts
This commit is contained in:
parent
c8184723f4
commit
6c49007b27
2 changed files with 1810 additions and 1086 deletions
|
|
@ -148,6 +148,40 @@ impl<'c, 'a: 'c> RuleFixer<'c, 'a> {
|
|||
Fix::new(replacement, target)
|
||||
}
|
||||
|
||||
/// Creates a fix command that inserts text before the given node.
|
||||
pub fn insert_text_before<T: GetSpan, S: Into<Cow<'a, str>>>(
|
||||
self,
|
||||
target: &T,
|
||||
text: S,
|
||||
) -> Fix<'a> {
|
||||
self.insert_text_before_range(target.span(), text)
|
||||
}
|
||||
|
||||
/// Creates a fix command that inserts text before the specified range in the source text.
|
||||
pub fn insert_text_before_range<S: Into<Cow<'a, str>>>(self, span: Span, text: S) -> Fix<'a> {
|
||||
self.insert_text_at(span.start, text)
|
||||
}
|
||||
|
||||
/// Creates a fix command that inserts text after the given node.
|
||||
pub fn insert_text_after<T: GetSpan, S: Into<Cow<'a, str>>>(
|
||||
self,
|
||||
target: &T,
|
||||
text: S,
|
||||
) -> Fix<'a> {
|
||||
self.insert_text_after_range(target.span(), text)
|
||||
}
|
||||
|
||||
/// Creates a fix command that inserts text after the specified range in the source text.
|
||||
pub fn insert_text_after_range<S: Into<Cow<'a, str>>>(self, span: Span, text: S) -> Fix<'a> {
|
||||
self.insert_text_at(span.end, text)
|
||||
}
|
||||
|
||||
/// Creates a fix command that inserts text at the specified index in the source text.
|
||||
#[allow(clippy::unused_self)]
|
||||
fn insert_text_at<S: Into<Cow<'a, str>>>(self, index: u32, text: S) -> Fix<'a> {
|
||||
Fix::new(text, Span::new(index, index))
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_self)]
|
||||
pub fn codegen(self) -> Codegen<'a, false> {
|
||||
Codegen::<false>::new()
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue