Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

challenge(formatter): quit hard line break if default clause has no consequent #768

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/biome_js_formatter/src/js/auxiliary/default_clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ impl FormatNodeRule<JsDefaultClause> for FormatJsDefaultClause {
}

if consequent.is_empty() {
write!(f, [hard_line_break()])
} else if first_child_is_block_stmt {
return Ok(());
}

if first_child_is_block_stmt {
write!(f, [space(), consequent.format()])
} else {
// no line break needed after because it is added by the indent in the switch statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,7 @@ break;// comment4b
```diff
--- Prettier
+++ Biome
@@ -1,9 +1,11 @@
switch (1) {
- default: // comment1
+ default:
+ // comment1
}

switch (2) {
- default: // comment2
+ default:
+ // comment2
//comment2a
}

@@ -18,10 +20,10 @@
@@ -18,10 +18,10 @@
break; // comment4b
}

Expand All @@ -76,13 +62,11 @@ break;// comment4b

```js
switch (1) {
default:
// comment1
default: // comment1
}

switch (2) {
default:
// comment2
default: // comment2
//comment2a
}

Expand Down