Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sad-boxes-lead.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed [#7917](https://github.com/biomejs/biome/issues/7917), where Biome removed the styles contained in a `<style lang="scss">`, when `experimentalFullSupportEnabled` is enabled.
39 changes: 39 additions & 0 deletions crates/biome_cli/tests/cases/handle_vue_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,45 @@ const props: Props = { title: "Hello" };
));
}

#[test]
fn full_support_enabled_and_scss_is_skipped() {
let fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

fs.insert(
"biome.json".into(),
r#"{ "html": { "formatter": {"enabled": true}, "linter": {"enabled": true}, "experimentalFullSupportEnabled": true } }"#.as_bytes(),
);

let astro_file_path = Utf8Path::new("file.vue");
fs.insert(
astro_file_path.into(),
r#"<html><head><title>Svelte</title></head><body></body></html>

<style lang="scss">
#id { font-family: comic-sans } .class { background: red}
</style>
"#
.as_bytes(),
);

let (fs, result) = run_cli(
fs,
&mut console,
Args::from(["check", "--write", "--unsafe", astro_file_path.as_str()].as_slice()),
);

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"full_support_enabled_and_scss_is_skipped",
fs,
console,
result,
));
}

#[test]
fn full_support_tsx() {
let fs = MemoryFileSystem::default();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: redactor(content)
---
## `biome.json`

```json
{
"html": {
"formatter": { "enabled": true },
"linter": { "enabled": true },
"experimentalFullSupportEnabled": true
}
}
```

## `file.vue`

```vue
<html>
<head>
<title>Svelte</title>
</head>
<body></body>
</html>

<style lang="scss">
#id { font-family: comic-sans } .class { background: red}
</style>

```

# Emitted Messages

```block
Checked 1 file in <TIME>. Fixed 1 file.
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl FormatNodeRule<HtmlEmbeddedContent> for FormatHtmlEmbeddedContent {
.ancestors()
.skip(1)
.find_map(HtmlElement::cast)?;
if element.is_supported_script_tag() || element.is_style_tag() {
if element.is_supported_script_tag() || element.is_supported_style_tag() {
Some(node.range())
} else {
None
Expand Down
5 changes: 5 additions & 0 deletions crates/biome_html_syntax/src/element_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ impl HtmlElement {
self.get_script_type().is_some_and(ScriptType::is_supported)
}

/// It's a style tag, and it doesn't contain `scss` as `lang`
pub fn is_supported_style_tag(&self) -> bool {
self.is_style_tag() && !self.is_sass_lang()
}

/// Returns the type of script for a `<script>` tag.
///
/// Returns `Some` [`ScriptType`] if this is a `<script>` tag, even if it
Expand Down