Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(format/html): keep at most 1 empty line between elements #4057

Merged

Conversation

dyc3
Copy link
Contributor

@dyc3 dyc3 commented Sep 23, 2024

Summary

Prettier preserves at most 1 empty line (2 newlines) between tags. This PR makes it so that Biome matches the newline preserving behavior of Prettier.

It feels a bit hacky, but it gets the job done. Since this was originally ported from the JsxChildList behavior, this code makes a bunch of assumptions about the parsing that are not true for the HTML parser. Planning to go through it eventually to clean it up and simplify it, which will be a lot easier to do when we have sufficient tests.

Caution

This PR is stacked on the following PRs. Do not merge it without merging the others and rebasing this branch. To review this PR, look at the last commit only.

fixes #3973

Test Plan

Added a few tests.

@github-actions github-actions bot added A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-HTML Language: HTML labels Sep 23, 2024
Copy link
Contributor

github-actions bot commented Sep 23, 2024

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 48534 48534 0
Passed 47341 47341 0
Failed 1193 1193 0
Panics 0 0 0
Coverage 97.54% 97.54% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6570 6570 0
Passed 2203 2203 0
Failed 4367 4367 0
Panics 0 0 0
Coverage 33.53% 33.53% 0.00%

ts/babel

Test result main count This PR count Difference
Total 680 680 0
Passed 608 608 0
Failed 72 72 0
Panics 0 0 0
Coverage 89.41% 89.41% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18433 18433 0
Passed 14114 14114 0
Failed 4319 4319 0
Panics 0 0 0
Coverage 76.57% 76.57% 0.00%

Copy link

codspeed-hq bot commented Sep 23, 2024

CodSpeed Performance Report

Merging #4057 will improve performances by 7.13%

Comparing 09-23-fix_format_hml_keep_at_most_1_empty_line_between_elements (0941f0b) with main (ab0f96e)

Summary

⚡ 1 improvements
✅ 106 untouched benchmarks

Benchmarks breakdown

Benchmark main 09-23-fix_format_hml_keep_at_most_1_empty_line_between_elements Change
react.production.min_3378072959512366797.js[cached] 2 ms 1.8 ms +7.13%

@dyc3 dyc3 force-pushed the 09-23-fix_format_hml_keep_at_most_1_empty_line_between_elements branch 2 times, most recently from 08f25fd to 8da85a7 Compare September 24, 2024 15:25
@github-actions github-actions bot removed the A-Tooling Area: internal tools label Sep 24, 2024
@dyc3 dyc3 marked this pull request as ready for review September 24, 2024 15:38
@dyc3 dyc3 requested review from a team September 24, 2024 15:38
@dyc3 dyc3 changed the title fix(format/hml): keep at most 1 empty line between elements fix(format/html): keep at most 1 empty line between elements Sep 24, 2024
@dyc3 dyc3 force-pushed the 09-23-fix_format_hml_keep_at_most_1_empty_line_between_elements branch from 8da85a7 to 0941f0b Compare September 25, 2024 10:32
@dyc3 dyc3 merged commit 9261a69 into main Sep 25, 2024
14 checks passed
@dyc3 dyc3 deleted the 09-23-fix_format_hml_keep_at_most_1_empty_line_between_elements branch September 25, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter A-Parser Area: parser L-HTML Language: HTML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📝 HTML: should preserve at most one newline trivia between elements
2 participants