From 02540987ecb839244ba2286574db0dc5e53cdc71 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Fri, 20 Sep 2024 09:08:31 -0400 Subject: [PATCH] feat(formatter/html): add line break at the end of files (#4010) --- crates/biome_html_formatter/src/html/auxiliary/root.rs | 2 ++ .../tests/specs/html/attributes/break.html.snap | 3 ++- .../tests/specs/html/attributes/no-break.html.snap | 3 ++- .../tests/specs/html/attributes/self-closing.html.snap | 3 ++- .../tests/specs/html/attributes/single-quotes.html.snap | 3 ++- .../tests/specs/html/long-content.html.snap | 3 ++- .../tests/specs/html/many-children.html.snap | 3 ++- .../tests/specs/html/self-closing.html.snap | 3 ++- 8 files changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/biome_html_formatter/src/html/auxiliary/root.rs b/crates/biome_html_formatter/src/html/auxiliary/root.rs index d3771b20fbf8..dc2ae941ca99 100644 --- a/crates/biome_html_formatter/src/html/auxiliary/root.rs +++ b/crates/biome_html_formatter/src/html/auxiliary/root.rs @@ -1,4 +1,5 @@ use crate::prelude::*; +use biome_formatter::write; use biome_html_syntax::HtmlRoot; #[derive(Debug, Clone, Default)] pub(crate) struct FormatHtmlRoot; @@ -16,6 +17,7 @@ impl FormatNodeRule for FormatHtmlRoot { if let Ok(eof) = node.eof_token() { eof.format().fmt(f)?; } + write!(f, [hard_line_break()])?; Ok(()) } diff --git a/crates/biome_html_formatter/tests/specs/html/attributes/break.html.snap b/crates/biome_html_formatter/tests/specs/html/attributes/break.html.snap index e759ed258dbb..0b0c8c50fd4f 100644 --- a/crates/biome_html_formatter/tests/specs/html/attributes/break.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/attributes/break.html.snap @@ -30,4 +30,5 @@ Attribute Position: Auto disabled class="w-full h-full bg-green text-white" id="foo" ->``` +> +``` diff --git a/crates/biome_html_formatter/tests/specs/html/attributes/no-break.html.snap b/crates/biome_html_formatter/tests/specs/html/attributes/no-break.html.snap index f54e1b647582..081955b463e0 100644 --- a/crates/biome_html_formatter/tests/specs/html/attributes/no-break.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/attributes/no-break.html.snap @@ -25,4 +25,5 @@ Attribute Position: Auto ----- ```html -
``` +
+``` diff --git a/crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html.snap b/crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html.snap index 4ee89251ba2d..4b7abf108ec0 100644 --- a/crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html.snap @@ -25,4 +25,5 @@ Attribute Position: Auto ----- ```html -``` + +``` diff --git a/crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html.snap b/crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html.snap index 2073db19c0cc..2c929f11289c 100644 --- a/crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html.snap @@ -25,4 +25,5 @@ Attribute Position: Auto ----- ```html -should keep "these" quotes``` +should keep "these" quotes +``` diff --git a/crates/biome_html_formatter/tests/specs/html/long-content.html.snap b/crates/biome_html_formatter/tests/specs/html/long-content.html.snap index 6b8dec426b89..fed6e7fb06d8 100644 --- a/crates/biome_html_formatter/tests/specs/html/long-content.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/long-content.html.snap @@ -36,4 +36,5 @@ Attribute Position: Auto ornare ipsum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut nec dapibus est. Maecenas orci purus, blandit eu faucibus eu, lacinia id turpis. -``` + +``` diff --git a/crates/biome_html_formatter/tests/specs/html/many-children.html.snap b/crates/biome_html_formatter/tests/specs/html/many-children.html.snap index 92693478f3c8..0e2376ecd900 100644 --- a/crates/biome_html_formatter/tests/specs/html/many-children.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/many-children.html.snap @@ -37,4 +37,5 @@ Attribute Position: Auto
Quuz
Corge
Grault
-``` + +``` diff --git a/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap b/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap index 9f690c1cbbe2..2582db7d13dd 100644 --- a/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap @@ -30,4 +30,5 @@ Attribute Position: Auto

-
``` + +```