Skip to content

Commit d9b0ef8

Browse files
[autofix.ci] apply automated fixes
1 parent 8bb564b commit d9b0ef8

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

crates/oxc_diagnostics/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub type Result<T> = std::result::Result<T, OxcDiagnostic>;
6262
use miette::{Diagnostic, SourceCode};
6363
pub use miette::{GraphicalReportHandler, GraphicalTheme, LabeledSpan, NamedSource, SourceSpan};
6464
use oxc_allocator::{Allocator, CloneIn};
65-
use oxc_span::{Span, SPAN};
65+
use oxc_span::{SPAN, Span};
6666

6767
/// Describes an error or warning that occurred.
6868
///
@@ -192,7 +192,7 @@ impl OxcDiagnostic {
192192
severity: Severity::Warning,
193193
code: OxcCode::default(),
194194
url: None,
195-
fix: None
195+
fix: None,
196196
}),
197197
}
198198
}
@@ -341,9 +341,6 @@ impl OxcDiagnostic {
341341
}
342342
}
343343

344-
345-
346-
347344
/// A completed, normalized fix ready to be applied to the source code.
348345
///
349346
/// Used internally by this module. Lint rules should use [`RuleFix`].

crates/oxc_linter/src/fixer/fix.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ impl<'a> Deref for RuleFix<'a> {
268268
}
269269
}
270270

271-
272271
// NOTE (@DonIsaac): having these variants is effectively the same as interning
273272
// single or 0-element Vecs. I experimented with using smallvec here, but the
274273
// resulting struct size was larger (40 bytes vs 32). So, we're sticking with

crates/oxc_linter/src/fixer/mod.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,8 @@ mod test {
631631
#[test]
632632
fn merge_fixes_in_composite_fix() {
633633
let source_text = "foo bar baz";
634-
let fixes = vec![Fix::new("quux".into(), Span::new(0, 3)), Fix::new("qux".into(), Span::new(4, 7))];
634+
let fixes =
635+
vec![Fix::new("quux".into(), Span::new(0, 3)), Fix::new("qux".into(), Span::new(4, 7))];
635636
let composite_fix = CompositeFix::Multiple(fixes);
636637
assert_fixed_corrected(source_text, "quux qux baz", composite_fix);
637638
}
@@ -658,7 +659,8 @@ mod test {
658659
#[should_panic(expected = "Fix must not be overlapped, last_pos: 3, span.start: 2")]
659660
fn overlapping_ranges_in_composite_fix() {
660661
let source_text = "foo bar baz";
661-
let fixes = vec![Fix::new("quux".into(), Span::new(0, 3)), Fix::new("qux".into(), Span::new(2, 5))];
662+
let fixes =
663+
vec![Fix::new("quux".into(), Span::new(0, 3)), Fix::new("qux".into(), Span::new(2, 5))];
662664
let composite_fix = CompositeFix::Multiple(fixes);
663665
assert_fixed_corrected(source_text, source_text, composite_fix);
664666
}
@@ -667,7 +669,8 @@ mod test {
667669
#[should_panic(expected = "Negative range is invalid: Span { start: 5, end: 2 }")]
668670
fn negative_ranges_in_composite_fix() {
669671
let source_text = "foo bar baz";
670-
let fixes = vec![Fix::new("quux".into(), Span::new(0, 3)), Fix::new("qux".into(), Span::new(5, 2))];
672+
let fixes =
673+
vec![Fix::new("quux".into(), Span::new(0, 3)), Fix::new("qux".into(), Span::new(5, 2))];
671674
let composite_fix = CompositeFix::Multiple(fixes);
672675
assert_fixed_corrected(source_text, source_text, composite_fix);
673676
}
@@ -685,7 +688,8 @@ mod test {
685688
#[test]
686689
fn merge_fixes_into_one() {
687690
let source_text = "foo\nbar";
688-
let fixes = vec![Fix::new("foo".into(), Span::new(1, 2)), Fix::new("bar".into(), Span::new(4, 5))];
691+
let fixes =
692+
vec![Fix::new("foo".into(), Span::new(1, 2)), Fix::new("bar".into(), Span::new(4, 5))];
689693
assert_fixes_merged(fixes, &Fix::new("fooo\nbar".into(), Span::new(1, 5)), source_text);
690694
}
691695

@@ -711,7 +715,8 @@ mod test {
711715
#[should_panic(expected = "Fix must not be overlapped, last_pos: 3, span.start: 2")]
712716
fn throw_error_when_ranges_overlap() {
713717
let source_text = "foo\nbar";
714-
let fixes = vec![Fix::new("foo".into(), Span::new(0, 3)), Fix::new("x".into(), Span::new(2, 5))];
718+
let fixes =
719+
vec![Fix::new("foo".into(), Span::new(0, 3)), Fix::new("x".into(), Span::new(2, 5))];
715720
assert_fixes_merged(fixes, &Fix::default(), source_text);
716721
}
717722

@@ -728,7 +733,8 @@ mod test {
728733
#[test]
729734
fn create_new_fix_with_new_range_when_fixes_is_multiple() {
730735
let source_text = "foo\nbar";
731-
let fixes = vec![Fix::new("baz".into(), Span::new(0, 3)), Fix::new("qux".into(), Span::new(4, 7))];
736+
let fixes =
737+
vec![Fix::new("baz".into(), Span::new(0, 3)), Fix::new("qux".into(), Span::new(4, 7))];
732738

733739
assert_fixes_merged(fixes, &Fix::new("baz\nqux".into(), Span::new(0, 7)), source_text);
734740
}

crates/oxc_linter/src/rules/typescript/prefer_function_type.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ fn check_member(member: &TSSignature, node: &AstNode<'_>, ctx: &LintContext<'_>)
202202
},
203203
&interface_decl.id.name,
204204
&suggestion
205-
).into(),
205+
)
206+
.into(),
206207
Span::new(node_start, node_end),
207208
);
208209
}
@@ -213,7 +214,8 @@ fn check_member(member: &TSSignature, node: &AstNode<'_>, ctx: &LintContext<'_>)
213214
if is_parent_exported { "export type" } else { "type" },
214215
&interface_decl.id.name,
215216
&suggestion
216-
).into(),
217+
)
218+
.into(),
217219
Span::new(node_start, node_end),
218220
)
219221
},

crates/oxc_linter/src/service/diagnostic_service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use crate::fixer::Message;
1212

1313
use super::{DiagnosticReporter, DiagnosticResult};
1414

15-
pub type DiagnosticTuple<'a> = (PathBuf, Vec<Message<'a>>);
15+
pub type DiagnosticTuple<'a> = (PathBuf, Vec<Message<'a>>);
1616
pub type DiagnosticSender<'a> = mpsc::Sender<Option<DiagnosticTuple<'a>>>;
17-
pub type DiagnosticReceiver<'a> = mpsc::Receiver<Option<DiagnosticTuple<'a>>>;
17+
pub type DiagnosticReceiver<'a> = mpsc::Receiver<Option<DiagnosticTuple<'a>>>;
1818

1919
/// Listens for diagnostics sent over a [channel](DiagnosticSender) by some job, and
2020
/// formats/reports them to the user.
@@ -67,7 +67,7 @@ pub struct DiagnosticService<'a> {
6767
receiver: DiagnosticReceiver<'a>,
6868
}
6969

70-
impl<'a> DiagnosticService<'a> {
70+
impl<'a> DiagnosticService<'a> {
7171
/// Create a new [`DiagnosticService`] that will render and report diagnostics using the
7272
/// provided [`DiagnosticReporter`].
7373
pub fn new(reporter: Box<dyn DiagnosticReporter>) -> Self {

crates/oxc_linter/src/service/runtime.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use oxc_span::{CompactStr, SourceType, VALID_EXTENSIONS};
2424

2525
use super::{DiagnosticSender, LintServiceOptions};
2626
use crate::{
27-
Fixer, Linter, Message,
27+
Fixer, Linter, Message,
2828
loader::{JavaScriptSource, LINT_PARTIAL_LOADER_EXTENSIONS, PartialLoader},
2929
module_record::ModuleRecord,
3030
utils::read_to_string,
@@ -563,9 +563,8 @@ impl Runtime {
563563
Ok(source_text) => source_text,
564564
Err(e) => {
565565
// ToDo: this will double format the report
566-
let diagnostic = OxcDiagnostic::error(
567-
"Failed to open file {path:?} with error \"{e}\""
568-
);
566+
let diagnostic =
567+
OxcDiagnostic::error("Failed to open file {path:?} with error \"{e}\"");
569568
let message = Message::new(diagnostic, None);
570569
tx_error.send(Some((Path::new(&path).to_path_buf(), vec![message]))).unwrap();
571570
return ModuleProcessOutput { path, processed_module: ProcessedModule::default() };

0 commit comments

Comments
 (0)