This repository was archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 653
feat(rome_js_formatter): Binary parentheses #3002
Merged
Merged
Conversation
This file contains hidden or 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
c6f51eb
to
7c5de7e
Compare
7c5de7e
to
fc56855
Compare
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
This PR refines the rules for setting parentheses around binary expression to more closely match Prettier's behaviour. It does so by re-using `OperatorPrecedence` enum from the parser crate (which is why it is moved to `rome_js_syntax`). Reviewed the updates to the prettier snapshots. **File Based Average Prettier Similarity**: 78.38% **Line Based Average Prettier Similarity**: 73.45%
fc56855
to
4ee2925
Compare
ematipico
approved these changes
Aug 4, 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.
Great progresses! 🎆
let current_precedence = current_operator.precedence(); | ||
let parent_precedence = parent_operator.precedence(); | ||
|
||
#[allow(clippy::if_same_then_else)] |
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.
I suppose you added this because it helps for readability?
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.
Yes, I find it easier to reason if every if
handles a specific case rather than grouping them all together because the main point here isn't about the body (which is a simple bool) but about the condition.
IWANABETHATGUY
pushed a commit
to IWANABETHATGUY/tools
that referenced
this pull request
Aug 22, 2022
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.
This PR refines the rules for setting parentheses around binary expression to more closely match Prettier's behaviour.
It does so by re-using
OperatorPrecedence
enum from the parser crate (which is why it is moved torome_js_syntax
).Tests
Reviewed the updates to the prettier snapshots.
File Based Average Prettier Similarity: 78.58% -> 78.85%
Line Based Average Prettier Similarity: 74.00% -> 74.25%