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

fix(formatter): Tighten has_line_breaks method #2581

Merged
merged 1 commit into from
May 13, 2022

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented May 13, 2022

The has_line_breaks method is a heuristic for determining if a FormatElement will break for certain, similar to Prettier's willBreak function.

This PR changes the function to return false for LineSuffix because a line suffix by itself doesn't introduce a line break. It only delays printing its content until the printer reaches the end of the line. A LineSuffix forces a group to expand but that only applies if the element is used inside of a Group, similar to soft_line_break that only expands to a line break outside of a group. That's why this PR changes the semantic to have soft_line_break and LineSuffix aligned.

@MichaReiser MichaReiser requested a review from leops May 13, 2022 11:13
@MichaReiser MichaReiser temporarily deployed to aws May 13, 2022 11:13 Inactive
@github-actions
Copy link

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 45878 45878 0
Passed 44938 44938 0
Failed 940 940 0
Panics 0 0 0
Coverage 97.95% 97.95% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 39 39 0
Passed 36 36 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.31% 92.31% 0.00%

ts/babel

Test result main count This PR count Difference
Total 588 588 0
Passed 519 519 0
Failed 69 69 0
Panics 0 0 0
Coverage 88.27% 88.27% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 16257 16257 0
Passed 12391 12391 0
Failed 3866 3866 0
Panics 0 0 0
Coverage 76.22% 76.22% 0.00%

@MichaReiser MichaReiser marked this pull request as draft May 13, 2022 11:17
@github-actions
Copy link

github-actions bot commented May 13, 2022

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 13, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 704160d
Status: ✅  Deploy successful!
Preview URL: https://4c1f7d55.tools-8rn.pages.dev

View logs

@MichaReiser MichaReiser force-pushed the fix/member-chain-heuristic branch from eab3733 to 704160d Compare May 13, 2022 12:33
@MichaReiser MichaReiser temporarily deployed to aws May 13, 2022 12:33 Inactive
@MichaReiser MichaReiser changed the title fix(formatter): Remove unstable has line breaks heuristic for member chains fix(formatter): Tighten has_line_breaks method May 13, 2022
@MichaReiser MichaReiser marked this pull request as ready for review May 13, 2022 12:37
@MichaReiser MichaReiser merged commit 7f5b18e into main May 13, 2022
@MichaReiser MichaReiser deleted the fix/member-chain-heuristic branch May 13, 2022 13:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants