Skip to content

Commit 03f5729

Browse files
committed
refactor(formatter): Remove unused multiline comment check in ternary (#16230)
Follow up #16224 > - Biome > - The same logic still exists > - https://github.com/biomejs/biome/blob/e7e0f6c14df92d83d08f86b1e57fc82b4df775b7/crates/biome_js_formatter/src/utils/conditional.rs#L197 > - In either case, the test did not fail > - always returning `false` > - removing related code like our diff above > - Prettier > - The most relevant lines are here > - https://github.com/prettier/prettier/blob/fd69335e513232c9b7aad78c93b42d8d3dd00ae7/src/language-js/print/ternary-old.js#L326-L344 > - As you expected, if change this to `const shouldBreak = false`, the test did not fail! From #16224 (comment)
1 parent ac3a92e commit 03f5729

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

crates/oxc_formatter/src/utils/conditional.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,6 @@ impl<'a> FormatConditionalLike<'a, '_> {
342342
}
343343
}
344344

345-
/// Checks if any part of the conditional has multiline comments
346-
#[inline]
347-
fn has_multiline_comment(_f: &Formatter<'_, 'a>) -> bool {
348-
// TODO: Implement multiline comment detection
349-
false
350-
}
351-
352345
/// Returns `true` if this is the root conditional expression and the parent is a [`StaticMemberExpression`].
353346
#[inline]
354347
fn is_parent_static_member_expression(&self, layout: ConditionalLayout) -> bool {
@@ -502,7 +495,6 @@ impl<'a> Format<'a> for FormatConditionalLike<'a, '_> {
502495
fn fmt(&self, f: &mut Formatter<'_, 'a>) {
503496
let layout = self.layout(f);
504497
let should_extra_indent = self.should_extra_indent(layout);
505-
let has_multiline_comment = Self::has_multiline_comment(f);
506498
let is_jsx_chain = self.options.jsx_chain || layout.is_jsx_chain();
507499

508500
let format_inner = format_with(|f| {
@@ -580,11 +572,8 @@ impl<'a> Format<'a> for FormatConditionalLike<'a, '_> {
580572
});
581573

582574
if layout.is_nested_test() || should_extra_indent {
583-
write!(f, [group(&soft_block_indent(&grouped)).should_expand(has_multiline_comment)]);
575+
write!(f, [group(&soft_block_indent(&grouped))]);
584576
} else {
585-
if has_multiline_comment {
586-
write!(f, [expand_parent()]);
587-
}
588577
grouped.fmt(f);
589578
}
590579
}

0 commit comments

Comments
 (0)