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
7 changes: 6 additions & 1 deletion crates/oxc_formatter/src/write/jsx/opening_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ impl<'a> Format<'a> for FormatOpeningElement<'a, '_> {
last_attribute_has_comment,
} => {
let format_inner = format_with(|f| {
write!(f, [format_open, soft_line_indent_or_space(&self.attributes())]);
write!(f, [format_open]);

let attributes = self.attributes();
if !attributes.is_empty() {
write!(f, [soft_line_indent_or_space(&attributes)]);
}

let comments = f.context().comments().comments_before(self.span.end);
FormatTrailingComments::Comments(comments).fmt(f);
Expand Down
3 changes: 2 additions & 1 deletion crates/oxc_formatter/src/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ use crate::{
use self::{
array_expression::FormatArrayExpression,
arrow_function_expression::is_multiline_template_starting_on_same_line,
block_statement::is_empty_block,
call_arguments::is_simple_module_import,
class::format_grouped_parameters_with_return_type_for_method,
object_like::ObjectLike,
Expand Down Expand Up @@ -1614,7 +1615,7 @@ impl<'a> FormatWrite<'a> for AstNode<'a, TSModuleBlock<'a>> {
let span = self.span();

write!(f, "{");
if body.is_empty() && directives.is_empty() {
if is_empty_block(&self.body) && directives.is_empty() {
write!(f, [format_dangling_comments(span).with_block_indent()]);
} else {
write!(f, [block_indent(&format_args!(directives, body))]);
Expand Down
Loading