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

feat(rome_js_formatter): If Statement Formatting #2957

Merged
merged 1 commit into from
Jul 28, 2022

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Jul 28, 2022

Summary

This PR brings the formatting of if statements closer to Prettier's formatting

  • Don't wrap single statements in block statements
  • create group around if and else
  • Force else on a new line if consequent isn't a block statement

This PR also fixes an issue where we added parentheses around string literals in places where this wasn't required.

Test Plan

I manually verified that the snapshot changes match prettier's output.

File Based Average Prettier Similarity: 77.75% -> 77.98%
Line Based Average Prettier Similarity: 72.91% -> 73.23%

@MichaReiser MichaReiser requested a review from ematipico as a code owner July 28, 2022 17:07
@MichaReiser MichaReiser temporarily deployed to aws July 28, 2022 17:07 Inactive
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 28, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7e3fe44
Status: ✅  Deploy successful!
Preview URL: https://95e10da3.tools-8rn.pages.dev
Branch Preview URL: https://feat-if-statement-formatting.tools-8rn.pages.dev

View logs

This PR brings the formatting of `if` statements closer to Prettier's formatting

* Don't wrap single statements in block statements
* create group around `if` and `else`
* Force `else` on a new line if consequent isn't a block statement

This PR also fixes an issue where we added parentheses around string literals in places where this wasn't required.
@MichaReiser MichaReiser force-pushed the feat/if-statement-formatting branch from 554716a to 7e3fe44 Compare July 28, 2022 17:12
@MichaReiser MichaReiser temporarily deployed to aws July 28, 2022 17:12 Inactive
@github-actions
Copy link

github-actions bot commented Jul 28, 2022

@MichaReiser MichaReiser merged commit 5ebec54 into main Jul 28, 2022
@MichaReiser MichaReiser deleted the feat/if-statement-formatting branch July 28, 2022 17:38
@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
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载