This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 664
fix(rome_js_formatter): correctly format sequence expressions #2541
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parser conformance results on ubuntu-latestjs/262
jsx/babel
ts/babel
ts/microsoft
|
Deploying with Cloudflare Pages
|
MichaReiser
reviewed
May 6, 2022
crates/rome_js_formatter/src/utils/format_sequence_expression.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_formatter/src/js/expressions/parenthesized_expression.rs
Outdated
Show resolved
Hide resolved
leops
reviewed
May 6, 2022
crates/rome_js_formatter/src/utils/format_sequence_expression.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_formatter/src/js/expressions/parenthesized_expression.rs
Outdated
Show resolved
Hide resolved
yassere
reviewed
May 22, 2022
crates/rome_js_formatter/tests/specs/prettier/js/objects/expression.js.snap
Outdated
Show resolved
Hide resolved
crates/rome_js_formatter/tests/specs/js/module/expression/sequence_expression.js.snap
Outdated
Show resolved
Hide resolved
crates/rome_js_formatter/src/js/expressions/sequence_expression.rs
Outdated
Show resolved
Hide resolved
ematipico
force-pushed
the
fix/sequence-expressions-indentation
branch
from
May 23, 2022 10:05
8b43836
to
093fe06
Compare
PR rebased. |
leops
reviewed
May 23, 2022
crates/rome_js_formatter/tests/specs/prettier/js/sequence-break/break.js.snap
Outdated
Show resolved
Hide resolved
MichaReiser
reviewed
May 23, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IR of Rome now seems to differ from Prettier.
Prettier
[
group([
"____________first",
",",
indent([line, "____________second"]),
",",
indent([line, "____________third"]),
",",
indent([line, "____________third"]),
",",
indent([line, "____________third"]),
",",
indent([line, "____________third"]),
",",
indent([line, "____________third"]),
]),
";",
hardline,
]
Rome
List [
Group(
List [
SyntaxTokenSlice("____________first"),
SyntaxTokenSlice(","),
Line(Soft),
Indent(
List [
Line(SoftOrSpace),
SyntaxTokenSlice("____________second"),
SyntaxTokenSlice(","),
],
),
Line(Soft),
Indent(
List [
Line(SoftOrSpace),
SyntaxTokenSlice("____________third"),
SyntaxTokenSlice(","),
],
),
Line(Soft),
Indent(
List [
Line(SoftOrSpace),
SyntaxTokenSlice("____________third"),
SyntaxTokenSlice(","),
],
),
Line(Soft),
Indent(
List [
Line(SoftOrSpace),
SyntaxTokenSlice("____________third"),
SyntaxTokenSlice(","),
],
),
Line(Soft),
Indent(
List [
Line(SoftOrSpace),
SyntaxTokenSlice("____________third"),
SyntaxTokenSlice(","),
],
),
Line(Soft),
Indent(
List [
Line(SoftOrSpace),
SyntaxTokenSlice("____________third"),
],
),
],
),
StaticToken(";"),
Line(Hard),
]
Why does Rome need the Line(soft)
. Seems to be redundant to the SoftOrSpace
.
crates/rome_js_formatter/src/js/expressions/sequence_expression.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_formatter/tests/specs/js/module/expression/sequence_expression.js.snap
Show resolved
Hide resolved
MichaReiser
reviewed
May 23, 2022
crates/rome_js_formatter/src/js/expressions/sequence_expression.rs
Outdated
Show resolved
Hide resolved
MichaReiser
reviewed
May 23, 2022
crates/rome_js_formatter/src/js/expressions/sequence_expression.rs
Outdated
Show resolved
Hide resolved
Thanks @MichaReiser , indeed that soft line break was redundant. I removed it. |
MichaReiser
approved these changes
May 23, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding the metrics to the test plan? Looks good.
MichaReiser
reviewed
May 23, 2022
crates/rome_js_formatter/src/js/expressions/sequence_expression.rs
Outdated
Show resolved
Hide resolved
MichaReiser
reviewed
May 23, 2022
crates/rome_js_formatter/src/js/expressions/sequence_expression.rs
Outdated
Show resolved
Hide resolved
ematipico
force-pushed
the
fix/sequence-expressions-indentation
branch
from
May 23, 2022 14:23
ca26abe
to
74888c2
Compare
Added! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes #2413
Test Plan
Added three cases that aim to fix them
Metrics
PR
File Based Average Prettier Similarity: 70.87%
Line Based Average Prettier Similarity: 64.93%
main
File Based Average Prettier Similarity: 70.84%
Line Based Average Prettier Similarity: 64.85%