Skip to content

Commit 051ceb6

Browse files
committed
chore: improve some format by running cargo +nightly fmt
1 parent e592883 commit 051ceb6

File tree

483 files changed

+1443
-1073
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

483 files changed

+1443
-1073
lines changed

apps/oxlint/src/command/lint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub enum OutputFormat {
162162

163163
impl FromStr for OutputFormat {
164164
type Err = String;
165+
165166
fn from_str(s: &str) -> Result<Self, Self::Err> {
166167
match s {
167168
"json" => Ok(Self::Json),
@@ -251,8 +252,7 @@ mod warning_options {
251252

252253
#[cfg(test)]
253254
mod lint_options {
254-
use std::fs::File;
255-
use std::path::PathBuf;
255+
use std::{fs::File, path::PathBuf};
256256

257257
use oxc_linter::AllowWarnDeny;
258258

apps/oxlint/src/command/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
mod ignore;
22
mod lint;
33

4-
use bpaf::Bpaf;
54
use std::path::PathBuf;
65

6+
use bpaf::Bpaf;
7+
78
pub use self::{
89
ignore::IgnoreOptions,
910
lint::{lint_command, LintCommand, OutputFormat, OutputOptions, WarningOptions},
@@ -64,8 +65,7 @@ fn expand_glob(paths: Vec<PathBuf>) -> Vec<PathBuf> {
6465

6566
#[cfg(test)]
6667
mod misc_options {
67-
use super::lint::lint_command;
68-
use super::MiscOptions;
68+
use super::{lint::lint_command, MiscOptions};
6969

7070
fn get_misc_options(arg: &str) -> MiscOptions {
7171
let args = arg.split(' ').map(std::string::ToString::to_string).collect::<Vec<_>>();

apps/oxlint/src/lint/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use ignore::gitignore::Gitignore;
21
use std::{env, io::BufWriter, time::Instant};
32

3+
use ignore::gitignore::Gitignore;
44
use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler};
55
use oxc_linter::{
66
partial_loader::LINT_PARTIAL_LOADER_EXT, LintOptions, LintService, LintServiceOptions, Linter,
@@ -122,7 +122,9 @@ impl Runner for LintRunner {
122122
if !path.is_file() {
123123
let path = if path.is_relative() { cwd.join(path) } else { path.clone() };
124124
return CliRunResult::InvalidOptions {
125-
message: format!("The tsconfig file {path:?} does not exist, Please provide a valid tsconfig file.", ),
125+
message: format!(
126+
"The tsconfig file {path:?} does not exist, Please provide a valid tsconfig file.",
127+
),
126128
};
127129
}
128130
}

apps/oxlint/src/walk.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ impl Walk {
141141
mod test {
142142
use std::{env, ffi::OsString};
143143

144-
use crate::IgnoreOptions;
145-
146144
use super::{Extensions, Walk};
145+
use crate::IgnoreOptions;
147146

148147
#[test]
149148
fn test_walk_with_extensions() {

crates/oxc_allocator/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ impl DerefMut for Allocator {
3737
mod test {
3838
use std::ops::Deref;
3939

40-
use crate::Allocator;
4140
use bumpalo::Bump;
4241

42+
use crate::Allocator;
43+
4344
#[test]
4445
fn test_api() {
4546
let bump = Bump::new();

crates/oxc_ast/src/ast/js.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use serde::Serialize;
2222
#[cfg(feature = "serialize")]
2323
use tsify::Tsify;
2424

25-
use super::inherit_variants;
26-
use super::{jsx::*, literal::*, ts::*};
25+
use super::{inherit_variants, jsx::*, literal::*, ts::*};
2726

2827
#[cfg(feature = "serialize")]
2928
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
@@ -1173,6 +1172,7 @@ impl<'a> AssignmentTarget<'a> {
11731172
pub fn get_identifier(&self) -> Option<&str> {
11741173
self.as_simple_assignment_target().and_then(|it| it.get_identifier())
11751174
}
1175+
11761176
pub fn get_expression(&self) -> Option<&Expression<'a>> {
11771177
self.as_simple_assignment_target().and_then(|it| it.get_expression())
11781178
}
@@ -2937,12 +2937,15 @@ impl MethodDefinitionKind {
29372937
pub fn is_constructor(&self) -> bool {
29382938
matches!(self, Self::Constructor)
29392939
}
2940+
29402941
pub fn is_method(&self) -> bool {
29412942
matches!(self, Self::Method)
29422943
}
2944+
29432945
pub fn is_set(&self) -> bool {
29442946
matches!(self, Self::Set)
29452947
}
2948+
29462949
pub fn is_get(&self) -> bool {
29472950
matches!(self, Self::Get)
29482951
}

crates/oxc_ast/src/ast/jsx.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ use serde::Serialize;
1414
#[cfg(feature = "serialize")]
1515
use tsify::Tsify;
1616

17-
use super::{js::*, literal::*, ts::*};
18-
19-
use super::inherit_variants;
17+
use super::{inherit_variants, js::*, literal::*, ts::*};
2018

2119
// 1.2 JSX Elements
2220

crates/oxc_ast/src/ast/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,6 @@ mod literal;
178178
mod macros;
179179
mod ts;
180180

181-
pub use self::{js::*, jsx::*, literal::*, ts::*};
182181
use macros::inherit_variants;
182+
183+
pub use self::{js::*, jsx::*, literal::*, ts::*};

crates/oxc_ast/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ pub use crate::{
5555
#[cfg(target_pointer_width = "64")]
5656
#[test]
5757
fn size_asserts() {
58-
use crate::ast;
5958
use static_assertions::assert_eq_size;
6059

60+
use crate::ast;
61+
6162
assert_eq_size!(ast::Statement, [u8; 16]);
6263
assert_eq_size!(ast::Expression, [u8; 16]);
6364
assert_eq_size!(ast::Declaration, [u8; 16]);

crates/oxc_ast/src/serialize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use oxc_allocator::{Box, Vec};
2+
use oxc_span::Span;
13
use serde::{
24
ser::{SerializeSeq, Serializer},
35
Serialize,
@@ -9,8 +11,6 @@ use crate::ast::{
911
Elision, FormalParameter, FormalParameterKind, FormalParameters, ObjectAssignmentTarget,
1012
ObjectPattern, Program, RegExpFlags, TSTypeAnnotation,
1113
};
12-
use oxc_allocator::{Box, Vec};
13-
use oxc_span::Span;
1414

1515
pub struct EcmaFormatter;
1616

crates/oxc_ast/src/syntax_directed_operations/gather_node_parts.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use crate::ast::*;
21
use oxc_span::Atom;
32

3+
use crate::ast::*;
4+
45
// TODO: <https://github.com/babel/babel/blob/419644f27c5c59deb19e71aaabd417a3bc5483ca/packages/babel-traverse/src/scope/index.ts#L61>
56
pub trait GatherNodeParts<'a> {
67
fn gather<F: FnMut(Atom<'a>)>(&self, f: &mut F);

crates/oxc_ast/src/visit/visit.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
77
use oxc_allocator::Vec;
88
use oxc_syntax::scope::ScopeFlags;
9+
use walk::*;
910

1011
use crate::{ast::*, ast_kind::AstKind};
1112

12-
use walk::*;
13-
1413
/// Syntax tree traversal
1514
pub trait Visit<'a>: Sized {
1615
#[allow(unused_variables)]

crates/oxc_ast/src/visit/visit_mut.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
use oxc_allocator::Vec;
44
use oxc_syntax::scope::ScopeFlags;
55

6-
use crate::{ast::*, AstType};
7-
86
#[allow(clippy::wildcard_imports)]
97
use self::walk_mut::*;
8+
use crate::{ast::*, AstType};
109

1110
/// Syntax tree traversal to mutate an exclusive borrow of a syntax tree in place.
1211
pub trait VisitMut<'a>: Sized {

crates/oxc_cfg/src/builder/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use crate::{BasicBlockId, EdgeType};
2-
31
use super::ControlFlowGraphBuilder;
2+
use crate::{BasicBlockId, EdgeType};
43

54
bitflags::bitflags! {
65
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -181,6 +180,7 @@ impl<'a, 'c> RefCtxCursor<'a, 'c> {
181180
self.0.flags.insert(CtxFlags::BREAK);
182181
self
183182
}
183+
184184
/// Allow continue entries in this context.
185185
pub fn allow_continue(self) -> Self {
186186
self.0.flags.insert(CtxFlags::CONTINUE);

crates/oxc_cfg/src/builder/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
mod context;
22

3-
use crate::ReturnInstructionKind;
43
use context::Ctx;
5-
64
pub use context::{CtxCursor, CtxFlags};
75
use oxc_syntax::node::AstNodeId;
86
use petgraph::Direction;
@@ -11,6 +9,7 @@ use super::{
119
BasicBlock, BasicBlockId, ControlFlowGraph, EdgeType, ErrorEdgeKind, Graph, Instruction,
1210
InstructionKind, IterationInstructionKind, LabeledInstruction,
1311
};
12+
use crate::ReturnInstructionKind;
1413

1514
#[derive(Debug, Default)]
1615
struct ErrorHarness(ErrorEdgeKind, BasicBlockId);

crates/oxc_cfg/src/dot.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ use petgraph::{
77
visit::EdgeRef,
88
};
99

10+
use super::IterationInstructionKind;
1011
use crate::{
1112
BasicBlock, ControlFlowGraph, EdgeType, Instruction, InstructionKind, LabeledInstruction,
1213
ReturnInstructionKind,
1314
};
1415

15-
use super::IterationInstructionKind;
16-
1716
pub trait DisplayDot {
1817
fn display_dot(&self) -> String;
1918
}

crates/oxc_cfg/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use petgraph::{
1313
pub mod graph {
1414
pub use petgraph::*;
1515
pub mod visit {
16-
pub use super::super::visit::*;
1716
pub use petgraph::visit::*;
17+
18+
pub use super::super::visit::*;
1819
}
1920
}
2021

crates/oxc_codegen/src/gen.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ use oxc_syntax::{
1010
precedence::{GetPrecedence, Precedence},
1111
};
1212

13-
use crate::annotation_comment::{gen_comment, get_leading_annotate_comment};
14-
use crate::{Codegen, Context, Operator};
13+
use crate::{
14+
annotation_comment::{gen_comment, get_leading_annotate_comment},
15+
Codegen, Context, Operator,
16+
};
1517

1618
pub trait Gen<const MINIFY: bool> {
1719
fn gen(&self, _p: &mut Codegen<{ MINIFY }>, _ctx: Context) {}

crates/oxc_codegen/src/lib.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,24 @@ mod sourcemap_builder;
1111

1212
use std::{borrow::Cow, ops::Range};
1313

14-
use rustc_hash::FxHashMap;
15-
16-
use oxc_ast::ast::{BlockStatement, Directive, Expression, Program, Statement};
17-
use oxc_ast::{Comment, Trivias};
14+
use oxc_ast::{
15+
ast::{BlockStatement, Directive, Expression, Program, Statement},
16+
Comment, Trivias,
17+
};
1818
use oxc_span::{Atom, Span};
1919
use oxc_syntax::{
2020
identifier::is_identifier_part,
2121
operator::{BinaryOperator, UnaryOperator, UpdateOperator},
2222
precedence::Precedence,
2323
symbol::SymbolId,
2424
};
25-
26-
use crate::operator::Operator;
27-
use crate::sourcemap_builder::SourcemapBuilder;
25+
use rustc_hash::FxHashMap;
2826

2927
pub use crate::{
3028
context::Context,
3129
gen::{Gen, GenExpr},
3230
};
31+
use crate::{operator::Operator, sourcemap_builder::SourcemapBuilder};
3332

3433
/// Code generator without whitespace removal.
3534
pub type CodeGenerator<'a> = Codegen<'a, false>;

crates/oxc_codegen/tests/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ fn for_stmt() {
139139
fn typescript() {
140140
test_ts("let x: string = `\\x01`;", "let x: string = `\\x01`;\n", false);
141141

142-
test_ts("function foo<T extends string>(x: T, y: string, ...restOfParams: Omit<T, 'x'>): T {\n\treturn x;\n}", "function foo<T extends string>(x: T, y: string, ...restOfParams: Omit<T, 'x'>): T {\n\treturn x;\n}\n", false);
142+
test_ts(
143+
"function foo<T extends string>(x: T, y: string, ...restOfParams: Omit<T, 'x'>): T {\n\treturn x;\n}",
144+
"function foo<T extends string>(x: T, y: string, ...restOfParams: Omit<T, 'x'>): T {\n\treturn x;\n}\n",
145+
false,
146+
);
143147

144148
test_ts(
145149
"let x: string[] = ['abc', 'def', 'ghi'];",
@@ -167,7 +171,11 @@ fn typescript() {
167171
);
168172
test_ts("let x: string['length'] = 123;", "let x: string['length'] = 123;\n", false);
169173

170-
test_ts("function isString(value: unknown): asserts value is string {\n\tif (typeof value !== 'string') {\n\t\tthrow new Error('Not a string');\n\t}\n}", "function isString(value: unknown): asserts value is string {\n\tif (typeof value !== 'string') {\n\t\tthrow new Error('Not a string');\n\t}\n}\n", false);
174+
test_ts(
175+
"function isString(value: unknown): asserts value is string {\n\tif (typeof value !== 'string') {\n\t\tthrow new Error('Not a string');\n\t}\n}",
176+
"function isString(value: unknown): asserts value is string {\n\tif (typeof value !== 'string') {\n\t\tthrow new Error('Not a string');\n\t}\n}\n",
177+
false,
178+
);
171179

172180
// type-only imports/exports
173181
test_ts("import type { Foo } from 'foo';", "import type { Foo } from 'foo';\n", false);

crates/oxc_diagnostics/src/graphic_reporter.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
/// origin file: https://github.com/zkat/miette/blob/75fea0935e495d0215518c80d32dd820910982e3/src/handlers/graphical.rs#L1
88
use std::fmt::{self, Write};
99

10-
use owo_colors::{OwoColorize, Style};
11-
use unicode_width::UnicodeWidthChar;
12-
1310
use miette::{
1411
Diagnostic, LabeledSpan, ReportHandler, Severity, SourceCode, SourceSpan, SpanContents,
1512
ThemeCharacters,
1613
};
14+
use owo_colors::{OwoColorize, Style};
15+
use unicode_width::UnicodeWidthChar;
1716

1817
use crate::graphical_theme::GraphicalTheme;
1918

crates/oxc_diagnostics/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct OxcDiagnostic {
3434

3535
impl Deref for OxcDiagnostic {
3636
type Target = Box<OxcDiagnosticInner>;
37+
3738
fn deref(&self) -> &Self::Target {
3839
&self.inner
3940
}

crates/oxc_diagnostics/src/reporter/checkstyle.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::{borrow::Cow, collections::HashMap};
22

3-
use crate::{Error, Severity};
4-
53
use super::{DiagnosticReporter, Info};
4+
use crate::{Error, Severity};
65

76
#[derive(Default)]
87
pub struct CheckstyleReporter {

crates/oxc_diagnostics/src/reporter/github.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use std::{
33
io::{BufWriter, Stdout, Write},
44
};
55

6-
use crate::{Error, Severity};
7-
86
use super::{writer, DiagnosticReporter, Info};
7+
use crate::{Error, Severity};
98

109
pub struct GithubReporter {
1110
writer: BufWriter<Stdout>,
@@ -40,7 +39,9 @@ fn format_github(diagnostic: &Error) -> String {
4039
let title = rule_id.map_or(Cow::Borrowed("oxlint"), Cow::Owned);
4140
let filename = escape_property(&filename);
4241
let message = escape_data(&message);
43-
format!("::{severity} file={filename},line={line},endLine={line},col={column},endColumn={column},title={title}::{message}\n")
42+
format!(
43+
"::{severity} file={filename},line={line},endLine={line},col={column},endColumn={column},title={title}::{message}\n"
44+
)
4445
}
4546

4647
fn escape_data(value: &str) -> String {

crates/oxc_diagnostics/src/reporter/graphical.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::io::{BufWriter, Stdout, Write};
22

3-
use crate::{Error, GraphicalReportHandler};
4-
53
use super::{writer, DiagnosticReporter};
4+
use crate::{Error, GraphicalReportHandler};
65

76
pub struct GraphicalReporter {
87
handler: GraphicalReportHandler,

0 commit comments

Comments
 (0)