Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_formatter): Format throw and return argument #2986

Merged
merged 2 commits into from
Aug 3, 2022

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Aug 2, 2022

This PR ensures that throw and return add parentheses around the argument for binary like expressions, sequence expressions and if the argument has any leading comments.

Testing

I manually reviewed all snapshot cases. The differences to prettier are around

  • formatting of binary like expressions -> separate PR
  • when to add or omit parentheses -> not part of this PR
  • comments -> requires the comments refactoring.

File Based Average Prettier Similarity: 77.98% -> 78.02%
Line Based Average Prettier Similarity: 73.23% -> 73.20%

The main reason why line based regresses is that the parenthesized / comments issues tend to spawn over multiple lines. However, these must be addressed as part of their own PR as they require significant architectural changes.

@MichaReiser MichaReiser temporarily deployed to aws August 2, 2022 09:15 Inactive
@MichaReiser MichaReiser marked this pull request as ready for review August 2, 2022 09:19
@github-actions
Copy link

github-actions bot commented Aug 2, 2022

@MichaReiser MichaReiser temporarily deployed to aws August 2, 2022 09:23 Inactive
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 2, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3940b57
Status:⚡️  Build in progress...

View logs

@MichaReiser MichaReiser temporarily deployed to aws August 2, 2022 13:28 Inactive
This PR ensures that `throw` and `return` add parentheses around the argument for binary like expressions, sequence expressions, and if the argument has any leading comments.

## Testing

 I manually reviewed all snapshot cases. The differences to prettier are around

 * formatting of binary like expressions -> separate PR
 * when to add or omit parentheses -> not part of this PR
 * comments -> requires the comments refactoring.
@MichaReiser MichaReiser temporarily deployed to aws August 3, 2022 07:16 Inactive
@MichaReiser MichaReiser merged commit c49e562 into main Aug 3, 2022
@MichaReiser MichaReiser deleted the feat/format-throw-return branch August 3, 2022 07:22
@ematipico ematipico added this to the 0.9.0 milestone Aug 3, 2022
IWANABETHATGUY pushed a commit to IWANABETHATGUY/tools that referenced this pull request Aug 22, 2022
@ematipico ematipico added the A-Formatter Area: formatter label Aug 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants