Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/oxc_formatter/src/formatter/format_element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ pub trait FormatElements {

/// Returns the end tag if:
/// * the last element is an end tag of `kind`
#[expect(unused)]
fn end_tag(&self, kind: TagKind) -> Option<&Tag>;
}

Expand Down
16 changes: 15 additions & 1 deletion crates/oxc_formatter/src/write/jsx/child_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl FormatJsxChildList {
let is_trailing_or_only_whitespace = children_iter.peek().is_none();

if is_trailing_or_only_whitespace || is_after_line_break {
multiline.write_separator(&JsxRawSpace, f);
multiline.write_separator_in_last_entry(&JsxRawSpace, f);
}
// Leading whitespace. Only possible if used together with a expression child
//
Expand Down Expand Up @@ -599,6 +599,20 @@ impl<'a> MultilineBuilder<'a> {
};
}

/// Writes a separator into the last entry if it is an entry.
fn write_separator_in_last_entry(
&mut self,
separator: &dyn Format<'a>,
f: &mut Formatter<'_, 'a>,
) {
if self.result.last().is_some_and(|element| element.end_tag(TagKind::Entry).is_some()) {
let last_index = self.result.len() - 1;
self.result.insert(last_index, f.intern(separator).unwrap());
} else {
self.write_content(separator, f);
}
}

fn finish(self) -> FormatMultilineChildren<'a> {
FormatMultilineChildren { layout: self.layout, elements: RefCell::new(self.result) }
}
Expand Down
3 changes: 1 addition & 2 deletions tasks/prettier_conformance/snapshots/prettier.js.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
js compatibility: 734/759 (96.71%)
js compatibility: 735/759 (96.84%)

# Failed

Expand Down Expand Up @@ -28,4 +28,3 @@ js compatibility: 734/759 (96.71%)
| jsx/fbt/test.js | 💥 | 84.06% |
| jsx/ignore/spread.js | 💥 | 83.33% |
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
| jsx/text-wrap/test.js | 💥 | 99.56% |
3 changes: 1 addition & 2 deletions tasks/prettier_conformance/snapshots/prettier.ts.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ts compatibility: 573/604 (94.87%)
ts compatibility: 574/604 (95.03%)

# Failed

Expand All @@ -7,7 +7,6 @@ ts compatibility: 573/604 (94.87%)
| jsx/fbt/test.js | 💥 | 84.06% |
| jsx/ignore/spread.js | 💥 | 83.33% |
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
| jsx/text-wrap/test.js | 💥 | 99.56% |
| typescript/arrow/comments.ts | 💥✨ | 44.44% |
| typescript/arrow/comments/issue-11100.ts | 💥 | 84.00% |
| typescript/as/as-const/as-const.ts | 💥 | 90.91% |
Expand Down
Loading