Skip to content

Commit 3bb35e5

Browse files
committed
fix: apply cargo fmt to fix CI formatting check
Recent commits introduced unformatted Rust code in transform.rs and integration_test.rs, causing the `cargo fmt --check` CI step to fail. https://claude.ai/code/session_01DWNfhcEuAQRhSXyzv3abY6
1 parent 5eb1a4f commit 3bb35e5

File tree

2 files changed

+44
-61
lines changed

2 files changed

+44
-61
lines changed

crates/oxc_angular_compiler/src/component/transform.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,16 +2336,13 @@ pub fn transform_angular_file(
23362336
decorator_texts: std::vec::Vec<String>,
23372337
}
23382338
let mut uninitialized_field_spans: Vec<Span> = Vec::new();
2339-
let mut stripped_field_decorates: std::vec::Vec<StrippedFieldDecorate> =
2340-
std::vec::Vec::new();
2339+
let mut stripped_field_decorates: std::vec::Vec<StrippedFieldDecorate> = std::vec::Vec::new();
23412340
if options.strip_uninitialized_fields {
23422341
for stmt in &parser_ret.program.body {
23432342
let class = match stmt {
23442343
Statement::ClassDeclaration(class) => Some(class.as_ref()),
23452344
Statement::ExportDefaultDeclaration(export) => match &export.declaration {
2346-
ExportDefaultDeclarationKind::ClassDeclaration(class) => {
2347-
Some(class.as_ref())
2348-
}
2345+
ExportDefaultDeclarationKind::ClassDeclaration(class) => Some(class.as_ref()),
23492346
_ => None,
23502347
},
23512348
Statement::ExportNamedDeclaration(export) => match &export.declaration {
@@ -2376,8 +2373,7 @@ pub fn transform_angular_file(
23762373
// Remove any decorator spans that fall within this field span
23772374
// to avoid overlapping edits (which cause byte boundary panics).
23782375
decorator_spans_to_remove.retain(|dec_span| {
2379-
!(dec_span.start >= field_span.start
2380-
&& dec_span.end <= field_span.end)
2376+
!(dec_span.start >= field_span.start && dec_span.end <= field_span.end)
23812377
});
23822378
uninitialized_field_spans.push(field_span);
23832379

@@ -2388,15 +2384,12 @@ pub fn transform_angular_file(
23882384
PropertyKey::StaticIdentifier(id) => id.name.to_string(),
23892385
_ => continue,
23902386
};
2391-
let mut non_angular_texts: std::vec::Vec<String> =
2392-
std::vec::Vec::new();
2387+
let mut non_angular_texts: std::vec::Vec<String> = std::vec::Vec::new();
23932388
for decorator in &prop.decorators {
23942389
// Extract decorator name to check if it's Angular
23952390
let dec_name = match &decorator.expression {
23962391
Expression::CallExpression(call) => match &call.callee {
2397-
Expression::Identifier(id) => {
2398-
Some(id.name.as_str())
2399-
}
2392+
Expression::Identifier(id) => Some(id.name.as_str()),
24002393
Expression::StaticMemberExpression(m) => {
24012394
Some(m.property.name.as_str())
24022395
}
@@ -2410,8 +2403,8 @@ pub fn transform_angular_file(
24102403
if !ANGULAR_DECORATOR_NAMES.contains(&name) {
24112404
let expr_span = decorator.expression.span();
24122405
non_angular_texts.push(
2413-
source[expr_span.start as usize
2414-
..expr_span.end as usize]
2406+
source
2407+
[expr_span.start as usize..expr_span.end as usize]
24152408
.to_string(),
24162409
);
24172410
}

crates/oxc_angular_compiler/tests/integration_test.rs

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9124,10 +9124,8 @@ export class TestComponent {
91249124
count = 0;
91259125
}
91269126
"#;
9127-
let options = ComponentTransformOptions {
9128-
strip_uninitialized_fields: true,
9129-
..Default::default()
9130-
};
9127+
let options =
9128+
ComponentTransformOptions { strip_uninitialized_fields: true, ..Default::default() };
91319129
let result =
91329130
transform_angular_file(&allocator, "test.component.ts", source, Some(&options), None);
91339131
assert!(!result.has_errors(), "Should not have errors: {:?}", result.diagnostics);
@@ -9163,10 +9161,8 @@ export class TestComponent {
91639161
count = 0;
91649162
}
91659163
"#;
9166-
let options = ComponentTransformOptions {
9167-
strip_uninitialized_fields: true,
9168-
..Default::default()
9169-
};
9164+
let options =
9165+
ComponentTransformOptions { strip_uninitialized_fields: true, ..Default::default() };
91709166
let result =
91719167
transform_angular_file(&allocator, "test.component.ts", source, Some(&options), None);
91729168
assert!(!result.has_errors(), "Should not have errors: {:?}", result.diagnostics);
@@ -9194,12 +9190,9 @@ class MyClass {
91949190
count = 0;
91959191
}
91969192
"#;
9197-
let options = ComponentTransformOptions {
9198-
strip_uninitialized_fields: true,
9199-
..Default::default()
9200-
};
9201-
let result =
9202-
transform_angular_file(&allocator, "test.ts", source, Some(&options), None);
9193+
let options =
9194+
ComponentTransformOptions { strip_uninitialized_fields: true, ..Default::default() };
9195+
let result = transform_angular_file(&allocator, "test.ts", source, Some(&options), None);
92039196

92049197
assert!(
92059198
result.code.contains("static label"),
@@ -9228,12 +9221,9 @@ class MyClass {
92289221
count = 0;
92299222
}
92309223
"#;
9231-
let options = ComponentTransformOptions {
9232-
strip_uninitialized_fields: true,
9233-
..Default::default()
9234-
};
9235-
let result =
9236-
transform_angular_file(&allocator, "test.ts", source, Some(&options), None);
9224+
let options =
9225+
ComponentTransformOptions { strip_uninitialized_fields: true, ..Default::default() };
9226+
let result = transform_angular_file(&allocator, "test.ts", source, Some(&options), None);
92379227

92389228
assert!(
92399229
!result.code.contains("declare") && !result.code.contains("name"),
@@ -9260,18 +9250,27 @@ class MyClass {
92609250
str = 'hello';
92619251
}
92629252
"#;
9263-
let options = ComponentTransformOptions {
9264-
strip_uninitialized_fields: true,
9265-
..Default::default()
9266-
};
9267-
let result =
9268-
transform_angular_file(&allocator, "test.ts", source, Some(&options), None);
9253+
let options =
9254+
ComponentTransformOptions { strip_uninitialized_fields: true, ..Default::default() };
9255+
let result = transform_angular_file(&allocator, "test.ts", source, Some(&options), None);
92699256

92709257
assert!(result.code.contains("items = []"), "items should be preserved. Got:\n{}", result.code);
9271-
assert!(result.code.contains("callback = () => {}"), "callback should be preserved. Got:\n{}", result.code);
9272-
assert!(result.code.contains("flag = false"), "flag should be preserved. Got:\n{}", result.code);
9258+
assert!(
9259+
result.code.contains("callback = () => {}"),
9260+
"callback should be preserved. Got:\n{}",
9261+
result.code
9262+
);
9263+
assert!(
9264+
result.code.contains("flag = false"),
9265+
"flag should be preserved. Got:\n{}",
9266+
result.code
9267+
);
92739268
assert!(result.code.contains("ref = null"), "ref should be preserved. Got:\n{}", result.code);
9274-
assert!(result.code.contains("str = 'hello'"), "str should be preserved. Got:\n{}", result.code);
9269+
assert!(
9270+
result.code.contains("str = 'hello'"),
9271+
"str should be preserved. Got:\n{}",
9272+
result.code
9273+
);
92759274
}
92769275

92779276
#[test]
@@ -9284,12 +9283,9 @@ class MyClass {
92849283
count = 0;
92859284
}
92869285
"#;
9287-
let options = ComponentTransformOptions {
9288-
strip_uninitialized_fields: false,
9289-
..Default::default()
9290-
};
9291-
let result =
9292-
transform_angular_file(&allocator, "test.ts", source, Some(&options), None);
9286+
let options =
9287+
ComponentTransformOptions { strip_uninitialized_fields: false, ..Default::default() };
9288+
let result = transform_angular_file(&allocator, "test.ts", source, Some(&options), None);
92939289

92949290
assert!(
92959291
result.code.contains("name"),
@@ -9318,10 +9314,8 @@ export class TestComponent {
93189314
count = 0;
93199315
}
93209316
"#;
9321-
let options = ComponentTransformOptions {
9322-
strip_uninitialized_fields: true,
9323-
..Default::default()
9324-
};
9317+
let options =
9318+
ComponentTransformOptions { strip_uninitialized_fields: true, ..Default::default() };
93259319
let result =
93269320
transform_angular_file(&allocator, "test.component.ts", source, Some(&options), None);
93279321

@@ -9413,10 +9407,8 @@ export class TestComponent {
94139407
}
94149408
}
94159409
"#;
9416-
let options = ComponentTransformOptions {
9417-
strip_uninitialized_fields: true,
9418-
..Default::default()
9419-
};
9410+
let options =
9411+
ComponentTransformOptions { strip_uninitialized_fields: true, ..Default::default() };
94209412
let result =
94219413
transform_angular_file(&allocator, "test.component.ts", source, Some(&options), None);
94229414
assert!(!result.has_errors(), "Should not have errors: {:?}", result.diagnostics);
@@ -9470,10 +9462,8 @@ export class TestComponent {
94709462
}
94719463
}
94729464
"#;
9473-
let options = ComponentTransformOptions {
9474-
strip_uninitialized_fields: true,
9475-
..Default::default()
9476-
};
9465+
let options =
9466+
ComponentTransformOptions { strip_uninitialized_fields: true, ..Default::default() };
94779467
let result =
94789468
transform_angular_file(&allocator, "test.component.ts", source, Some(&options), None);
94799469
assert!(!result.has_errors(), "Should not have errors: {:?}", result.diagnostics);

0 commit comments

Comments
 (0)