diff --git a/.changeset/flat-rockets-battle.md b/.changeset/flat-rockets-battle.md new file mode 100644 index 000000000000..c5893db20a85 --- /dev/null +++ b/.changeset/flat-rockets-battle.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": patch +--- + +Biome now keeps a blank line after the frontmatter section in Astro files. diff --git a/crates/biome_cli/tests/cases/handle_astro_files.rs b/crates/biome_cli/tests/cases/handle_astro_files.rs index 5bccbd4ba2d3..8c2808a146d1 100644 --- a/crates/biome_cli/tests/cases/handle_astro_files.rs +++ b/crates/biome_cli/tests/cases/handle_astro_files.rs @@ -223,6 +223,9 @@ let schema = z.object().optional(); schema + sure() --- + + + Astro - 15 │ + 17 │ + 18 │ i Consider adding a generic font family as a fallback. diff --git a/crates/biome_html_formatter/src/html/auxiliary/root.rs b/crates/biome_html_formatter/src/html/auxiliary/root.rs index b12c8ebf4e14..d72a0a63486d 100644 --- a/crates/biome_html_formatter/src/html/auxiliary/root.rs +++ b/crates/biome_html_formatter/src/html/auxiliary/root.rs @@ -18,7 +18,7 @@ impl FormatNodeRule for FormatHtmlRoot { } if let Some(frontmatter) = frontmatter { - write!(f, [frontmatter.format(), hard_line_break()])?; + write!(f, [frontmatter.format(), empty_line()])?; } if let Some(directive) = directive { diff --git a/crates/biome_html_formatter/tests/specs/html/component-frameworks/astro-component-casing.astro.snap b/crates/biome_html_formatter/tests/specs/html/component-frameworks/astro-component-casing.astro.snap index a230f4517465..7b69b59a43b4 100644 --- a/crates/biome_html_formatter/tests/specs/html/component-frameworks/astro-component-casing.astro.snap +++ b/crates/biome_html_formatter/tests/specs/html/component-frameworks/astro-component-casing.astro.snap @@ -41,6 +41,7 @@ Self close void elements: never import Button from './Button.astro'; import TextInput from './TextInput.astro'; --- + diff --git a/crates/biome_html_formatter/tests/specs/html/frontmatter.html.snap b/crates/biome_html_formatter/tests/specs/html/frontmatter.html.snap index 2e5d3a96027f..808ad5a9c7d8 100644 --- a/crates/biome_html_formatter/tests/specs/html/frontmatter.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/frontmatter.html.snap @@ -36,5 +36,6 @@ Self close void elements: never --- layout: foo --- + Test abc. ``` diff --git a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/custom-parser.html.snap b/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/custom-parser.html.snap deleted file mode 100644 index eb1b6571d66f..000000000000 --- a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/custom-parser.html.snap +++ /dev/null @@ -1,66 +0,0 @@ ---- -source: crates/biome_formatter_test/src/snapshot_builder.rs -info: html/front-matter/custom-parser.html ---- -# Input - -```html ----mycustomparser - -title: Hello -slug: home - ---- - -

- Hello world!

- -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Biome -@@ -4,5 +4,4 @@ - slug: home - - --- -- -

Hello world!

-``` - -# Output - -```html ----mycustomparser - -title: Hello -slug: home - ---- -

Hello world!

-``` - -# Errors -``` -custom-parser.html:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Frontmatter is only valid inside Astro files. - - > 1 │ ---mycustomparser - │ ^^^^^^^^^^^^^^^^^ - > 2 │ - > 3 │ title: Hello - > 4 │ slug: home - > 5 │ - > 6 │ --- - │ ^^^ - 7 │ - 8 │

- - i Remove it or rename the file to have the .astro extension. - - -``` diff --git a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/empty.html.snap b/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/empty.html.snap deleted file mode 100644 index 21b2942d1339..000000000000 --- a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/empty.html.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: crates/biome_formatter_test/src/snapshot_builder.rs -info: html/front-matter/empty.html ---- -# Input - -```html ---- ---- - -

- Hello world!

- -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Biome -@@ -1,4 +1,3 @@ - --- - --- -- -

Hello world!

-``` - -# Output - -```html ---- ---- -

Hello world!

-``` - -# Errors -``` -empty.html:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Frontmatter is only valid inside Astro files. - - > 1 │ --- - │ ^^^ - > 2 │ --- - │ ^^^ - 3 │ - 4 │

- - i Remove it or rename the file to have the .astro extension. - - -``` diff --git a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/empty2.html.snap b/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/empty2.html.snap deleted file mode 100644 index ab29229871db..000000000000 --- a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/empty2.html.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: crates/biome_formatter_test/src/snapshot_builder.rs -info: html/front-matter/empty2.html ---- -# Input - -```html ---- ---- - -
---- -
- -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Biome -@@ -1,4 +1,3 @@ - --- - --- -- -
---
-``` - -# Output - -```html ---- ---- -
---
-``` - -# Errors -``` -empty2.html:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Frontmatter is only valid inside Astro files. - - > 1 │ --- - │ ^^^ - > 2 │ --- - │ ^^^ - 3 │ - 4 │
- - i Remove it or rename the file to have the .astro extension. - -empty2.html:5:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Unexpected value or character. - - 4 │
- > 5 │ --- - │ ^^^ - 6 │
- 7 │ - - i Expected one of: - - - element - - text - - closing block - - -``` diff --git a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/issue-9042-no-empty-line.html.snap b/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/issue-9042-no-empty-line.html.snap deleted file mode 100644 index 6caf9721766e..000000000000 --- a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/issue-9042-no-empty-line.html.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: crates/biome_formatter_test/src/snapshot_builder.rs -info: html/front-matter/issue-9042-no-empty-line.html ---- -# Input - -```html ---- -layout: foo ---- -Test abc. - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Biome -@@ -1,5 +1,4 @@ - --- - layout: foo - --- -- - Test abc. -``` - -# Output - -```html ---- -layout: foo ---- -Test abc. -``` - -# Errors -``` -issue-9042-no-empty-line.html:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Frontmatter is only valid inside Astro files. - - > 1 │ --- - │ ^^^ - > 2 │ layout: foo - > 3 │ --- - │ ^^^ - 4 │ Test abc. - - i Remove it or rename the file to have the .astro extension. - - -``` diff --git a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/issue-9042.html.snap b/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/issue-9042.html.snap deleted file mode 100644 index c360307adf1f..000000000000 --- a/crates/biome_html_formatter/tests/specs/prettier/html/front-matter/issue-9042.html.snap +++ /dev/null @@ -1,57 +0,0 @@ ---- -source: crates/biome_formatter_test/src/snapshot_builder.rs -info: html/front-matter/issue-9042.html ---- -# Input - -```html ---- -layout: foo ---- - -Test abc. - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Biome -@@ -1,5 +1,4 @@ - --- - layout: foo - --- -- - Test abc. -``` - -# Output - -```html ---- -layout: foo ---- -Test abc. -``` - -# Errors -``` -issue-9042.html:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Frontmatter is only valid inside Astro files. - - > 1 │ --- - │ ^^^ - > 2 │ layout: foo - > 3 │ --- - │ ^^^ - 4 │ - 5 │ Test - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Biome -@@ -2,7 +2,6 @@ - invalid: - invalid: - --- -- - - - -``` - -# Output - -```html ---- - invalid: -invalid: ---- - - - - -``` - -# Errors -``` -invalid.html:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Frontmatter is only valid inside Astro files. - - > 1 │ --- - │ ^^^ - > 2 │ invalid: - > 3 │ invalid: - > 4 │ --- - │ ^^^ - 5 │ - - i Remove it or rename the file to have the .astro extension. - - -``` diff --git a/crates/biome_html_formatter/tests/specs/prettier/html/yaml/yaml.html.snap b/crates/biome_html_formatter/tests/specs/prettier/html/yaml/yaml.html.snap index b9f40d113338..0e0f60203cb3 100644 --- a/crates/biome_html_formatter/tests/specs/prettier/html/yaml/yaml.html.snap +++ b/crates/biome_html_formatter/tests/specs/prettier/html/yaml/yaml.html.snap @@ -24,15 +24,13 @@ hello: world ```diff --- Prettier +++ Biome -@@ -1,7 +1,6 @@ +@@ -1,5 +1,5 @@ --- -hello: world +hello: world --- -- + - - ``` # Output @@ -41,6 +39,7 @@ hello: world --- hello: world --- +