diff --git a/CHANGELOG.md b/CHANGELOG.md index 348d64aca7ae..f53dec137cbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -1911,7 +1913,7 @@ The following rules are now recommended: The code action now removes any whitespace between the parameter name and its initialization. -- Relax [noConfusingArrow](https://biomejs.dev/linter/rules/no-confusing-arrow/) +- Relax `noConfusingArrow` All arrow functions that enclose its parameter with parenthesis are allowed. Thus, the following snippet no longer trigger the rule: diff --git a/crates/biome_formatter/src/buffer.rs b/crates/biome_formatter/src/buffer.rs index 420990336ca7..5012067d2c96 100644 --- a/crates/biome_formatter/src/buffer.rs +++ b/crates/biome_formatter/src/buffer.rs @@ -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 => diff --git a/crates/biome_js_formatter/tests/specs/ts/issue1511.ts b/crates/biome_js_formatter/tests/specs/ts/issue1511.ts new file mode 100644 index 000000000000..5ea570eb2e82 --- /dev/null +++ b/crates/biome_js_formatter/tests/specs/ts/issue1511.ts @@ -0,0 +1,3 @@ +call(a, function (b: () => t1 | t2) {}); + +call(a, (b: () => t1 | t2) => {}); diff --git a/crates/biome_js_formatter/tests/specs/ts/issue1511.ts.snap b/crates/biome_js_formatter/tests/specs/ts/issue1511.ts.snap new file mode 100644 index 000000000000..c39f8cb433b1 --- /dev/null +++ b/crates/biome_js_formatter/tests/specs/ts/issue1511.ts.snap @@ -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) => {}); +``` + + diff --git a/website/src/content/docs/internals/changelog.mdx b/website/src/content/docs/internals/changelog.mdx index 729bddb5ee72..2d33a4098e7a 100644 --- a/website/src/content/docs/internals/changelog.mdx +++ b/website/src/content/docs/internals/changelog.mdx @@ -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 @@ -1917,7 +1919,7 @@ The following rules are now recommended: The code action now removes any whitespace between the parameter name and its initialization. -- Relax [noConfusingArrow](https://biomejs.dev/linter/rules/no-confusing-arrow/) +- Relax `noConfusingArrow` All arrow functions that enclose its parameter with parenthesis are allowed. Thus, the following snippet no longer trigger the rule: diff --git a/website/src/content/docs/zh-cn/internals/changelog.mdx b/website/src/content/docs/zh-cn/internals/changelog.mdx index 0eb0fdcdc773..36ce590a7b15 100644 --- a/website/src/content/docs/zh-cn/internals/changelog.mdx +++ b/website/src/content/docs/zh-cn/internals/changelog.mdx @@ -1216,7 +1216,7 @@ The following rules are promoted: #### Removed rules -- Remove [noConfusingArrow](https://biomejs.dev/linter/rules/no-confusing-arrow/). +- Remove `noConfusingArrow` Code formatters, such as prettier and Biome, always adds parentheses around the parameter or the body of an arrow function. This makes the rule useless. @@ -1876,7 +1876,7 @@ The following rules are now recommended: The code action now removes any whitespace between the parameter name and its initialization. -- Relax [noConfusingArrow](https://biomejs.dev/linter/rules/no-confusing-arrow/) +- Relax `noConfusingArrow` All arrow functions that enclose its parameter with parenthesis are allowed. Thus, the following snippet no longer trigger the rule: