Skip to content

Commit 8ca3f7f

Browse files
authored
feat(parse/html): parse astro directives (#9128)
1 parent 3ca066b commit 8ca3f7f

42 files changed

Lines changed: 3442 additions & 86 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#9107](https://github.com/biomejs/biome/issues/9107): The HTML parser can now correctly parse Astro directives (client/set/class/is/server), which fixes the formatting for Astro directives.

crates/biome_cli/tests/cases/handle_astro_files.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,6 @@ let {
10311031
10321032
<!-- used as value here -->
10331033
<AvatarPrimitive.Fallback
1034-
bind:ref
10351034
class="something nice"
10361035
/>
10371036
"#

crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/use_import_type_not_triggered_for_enum_in_template_v2.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ let {
2828
2929
<!-- used as value here -->
3030
<AvatarPrimitive.Fallback
31-
bind:ref
3231
class="something nice"
3332
/>
3433

crates/biome_html_factory/src/generated/node_factory.rs

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_html_factory/src/generated/syntax_factory.rs

Lines changed: 189 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
2+
3+
use crate::prelude::*;
4+
use biome_html_syntax::AnyAstroDirective;
5+
#[derive(Debug, Clone, Default)]
6+
pub(crate) struct FormatAnyAstroDirective;
7+
impl FormatRule<AnyAstroDirective> for FormatAnyAstroDirective {
8+
type Context = HtmlFormatContext;
9+
fn fmt(&self, node: &AnyAstroDirective, f: &mut HtmlFormatter) -> FormatResult<()> {
10+
match node {
11+
AnyAstroDirective::AstroClassDirective(node) => node.format().fmt(f),
12+
AnyAstroDirective::AstroClientDirective(node) => node.format().fmt(f),
13+
AnyAstroDirective::AstroDefineDirective(node) => node.format().fmt(f),
14+
AnyAstroDirective::AstroIsDirective(node) => node.format().fmt(f),
15+
AnyAstroDirective::AstroServerDirective(node) => node.format().fmt(f),
16+
AnyAstroDirective::AstroSetDirective(node) => node.format().fmt(f),
17+
}
18+
}
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
22
3+
pub(crate) mod directive;
34
pub(crate) mod frontmatter_element;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::prelude::*;
2+
use biome_formatter::write;
3+
use biome_html_syntax::AstroClassDirective;
4+
#[derive(Debug, Clone, Default)]
5+
pub(crate) struct FormatAstroClassDirective;
6+
impl FormatNodeRule<AstroClassDirective> for FormatAstroClassDirective {
7+
fn fmt_fields(&self, node: &AstroClassDirective, f: &mut HtmlFormatter) -> FormatResult<()> {
8+
let fields = node.as_fields();
9+
write!(f, [fields.class_token.format(), fields.value.format()])
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::prelude::*;
2+
use biome_formatter::write;
3+
use biome_html_syntax::AstroClientDirective;
4+
#[derive(Debug, Clone, Default)]
5+
pub(crate) struct FormatAstroClientDirective;
6+
impl FormatNodeRule<AstroClientDirective> for FormatAstroClientDirective {
7+
fn fmt_fields(&self, node: &AstroClientDirective, f: &mut HtmlFormatter) -> FormatResult<()> {
8+
let fields = node.as_fields();
9+
write!(f, [fields.client_token.format(), fields.value.format()])
10+
}
11+
}

0 commit comments

Comments
 (0)