+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,18 @@ impl Format<JsFormatContext> for ArrowChain {
soft_block_indent(&format_tail_body),
text(")")
])]
)
)?;
} else {
write!(f, [format_tail_body])
write!(f, [format_tail_body])?;
}

// Format the trailing comments of all arrow function EXCEPT the first one because
// the comments of the head get formatted as part of the `FormatJsArrowFunctionExpression` call.
for arrow in self.arrows().skip(1) {
write!(f, [format_trailing_comments(arrow.syntax())])?;
}

Ok(())
});

let format_tail_body = format_with(|f| {
Expand Down Expand Up @@ -489,7 +497,7 @@ impl Format<JsFormatContext> for ArrowChain {
.should_expand(break_before_chain),
space(),
tail.fat_arrow_token().format(),
indent_if_group_breaks(&format_tail_body, group_id)
indent_if_group_breaks(&format_tail_body, group_id),
]
)?;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
x = (bifornCringerMoshedPerplexSawder) => ((askTrovenaBeenaDependsRowans, glimseGlyphsHazardNoopsTieTie) => (f00) => {
averredBathersBoxroomBuggyNurl();
} // BOOM
)

x2 = (a) => ((askTrovenaBeenaDependsRowans1, askTrovenaBeenaDependsRowans2, askTrovenaBeenaDependsRowans3) => {
c();
} /* ! */ // KABOOM
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
source: crates/rome_js_formatter/tests/spec_test.rs
expression: arrow_chain_comments.js
---
# Input
x = (bifornCringerMoshedPerplexSawder) => ((askTrovenaBeenaDependsRowans, glimseGlyphsHazardNoopsTieTie) => (f00) => {
averredBathersBoxroomBuggyNurl();
} // BOOM
)

x2 = (a) => ((askTrovenaBeenaDependsRowans1, askTrovenaBeenaDependsRowans2, askTrovenaBeenaDependsRowans3) => {
c();
} /* ! */ // KABOOM
)

=============================
# Outputs
## Output 1
-----
Indent style: Tab
Line width: 80
Quote style: Double Quotes
Quote properties: As needed
-----
x =
(bifornCringerMoshedPerplexSawder) =>
(askTrovenaBeenaDependsRowans, glimseGlyphsHazardNoopsTieTie) =>
(f00) => {
averredBathersBoxroomBuggyNurl();
}; // BOOM

x2 =
(a) =>
(
askTrovenaBeenaDependsRowans1,
askTrovenaBeenaDependsRowans2,
askTrovenaBeenaDependsRowans3,
) => {
c();
} /* ! */; // KABOOM

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载