Skip to content

Commit

Permalink
fix(js_formatter): fix #1511
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos committed Jan 12, 2024
1 parent e7fe085 commit ac04415
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom

- Fix [#1172](https://github.com/biomejs/biome/issues/1172). Fix placement of line comment after function expression parentheses, they are now attached to first statement in body. Contributed by @kalleep

- Fix [#1511](https://github.com/biomejs/biome/issues/1511) that made the JavaScript formatter crash. COntributed @Conaclos

### JavaScript APIs

### Linter
Expand Down
4 changes: 0 additions & 4 deletions crates/biome_formatter/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,6 @@ fn clean_interned(
Some((mut cleaned, rest)) => {
let mut is_in_expanded_conditional_content = false;
for element in rest {
if is_in_expanded_conditional_content {
continue;
}

let element = match element {
FormatElement::Tag(Tag::StartConditionalContent(condition))
if condition.mode == PrintMode::Expanded =>
Expand Down
3 changes: 3 additions & 0 deletions crates/biome_js_formatter/tests/specs/ts/issue1511.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
call(a, function (b: () => t1 | t2) {});

call(a, (b: () => t1 | t2) => {});
43 changes: 43 additions & 0 deletions crates/biome_js_formatter/tests/specs/ts/issue1511.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: ts/issue1511.ts
---

# Input

```ts
call(a, function (b: () => t1 | t2) {});

call(a, (b: () => t1 | t2) => {});

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
JSX quote style: Double Quotes
Quote properties: As needed
Trailing comma: All
Semicolons: Always
Arrow parentheses: Always
Bracket spacing: true
Bracket same line: false
-----

```ts
call(a, function (b: () => t1 | t2) {});

call(a, (b: () => t1 | t2) => {});
```


2 changes: 2 additions & 0 deletions website/src/content/docs/internals/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom

- Fix [#1172](https://github.com/biomejs/biome/issues/1172). Fix placement of line comment after function expression parentheses, they are now attached to first statement in body. Contributed by @kalleep

- Fix [#1511](https://github.com/biomejs/biome/issues/1511) that made the JavaScript formatter crash. COntributed @Conaclos

### JavaScript APIs

### Linter
Expand Down

0 comments on commit ac04415

Please sign in to comment.