diff --git a/.changeset/petite-mice-say.md b/.changeset/petite-mice-say.md
new file mode 100644
index 000000000000..b0d8c6cba57c
--- /dev/null
+++ b/.changeset/petite-mice-say.md
@@ -0,0 +1,5 @@
+---
+"@biomejs/biome": patch
+---
+
+Fixed [`#7912`](https://github.com/biomejs/biome/issues/7912), where Biome incorrectly added a leading newline to the code contained inside the Astro frontmatter.
diff --git a/.changeset/tricky-masks-cry.md b/.changeset/tricky-masks-cry.md
new file mode 100644
index 000000000000..8caefa95b2f4
--- /dev/null
+++ b/.changeset/tricky-masks-cry.md
@@ -0,0 +1,5 @@
+---
+"@biomejs/biome": patch
+---
+
+Fixed a regression where formatting wasn't correctly applied when applying safe/unsafe fixes via the Biome linter.
diff --git a/crates/biome_cli/src/execute/process_file/lint_and_assist.rs b/crates/biome_cli/src/execute/process_file/lint_and_assist.rs
index 21aacf62134e..861cdecee373 100644
--- a/crates/biome_cli/src/execute/process_file/lint_and_assist.rs
+++ b/crates/biome_cli/src/execute/process_file/lint_and_assist.rs
@@ -73,7 +73,7 @@ pub(crate) fn analyze_with_guard<'ctx>(
.guard()
.fix_file(
*fix_mode,
- false,
+ features_supported.supports_format(),
categories,
only.clone(),
skip.clone(),
diff --git a/crates/biome_cli/tests/cases/handle_astro_files.rs b/crates/biome_cli/tests/cases/handle_astro_files.rs
index 48a2faa204d0..7b2ceccc6a4b 100644
--- a/crates/biome_cli/tests/cases/handle_astro_files.rs
+++ b/crates/biome_cli/tests/cases/handle_astro_files.rs
@@ -748,3 +748,56 @@ fn does_not_throw_parse_error_for_return_full_support() {
result,
));
}
+
+#[test]
+fn issue_7912() {
+ let fs = MemoryFileSystem::default();
+ let mut console = BufferConsole::default();
+
+ fs.insert(
+ "biome.json".into(),
+ r#"{ "html": { "experimentalFullSupportEnabled": true, "formatter": { "enabled": true } } }"#.as_bytes(),
+ );
+
+ let astro_file_path = Utf8Path::new("file.astro");
+ fs.insert(
+ astro_file_path.into(),
+ r#"---
+ const title = "Hello World";
+---
+
+
+
+ {title}
+
+
+ {title}
+
+"#
+ .as_bytes(),
+ );
+
+ let (fs, result) = run_cli(
+ fs,
+ &mut console,
+ Args::from(
+ [
+ "lint",
+ "--write",
+ "--only=suspicious/noDebugger",
+ astro_file_path.as_str(),
+ ]
+ .as_slice(),
+ ),
+ );
+
+ assert!(result.is_ok(), "run_cli returned {result:?}");
+
+ assert_cli_snapshot(SnapshotPayload::new(
+ module_path!(),
+ "issue_7912",
+ fs,
+ console,
+ result,
+ ));
+}
diff --git a/crates/biome_cli/tests/cases/included_files.rs b/crates/biome_cli/tests/cases/included_files.rs
index 351cb3efb465..de217038a32a 100644
--- a/crates/biome_cli/tests/cases/included_files.rs
+++ b/crates/biome_cli/tests/cases/included_files.rs
@@ -9,7 +9,7 @@ const UNFORMATTED: &str = " statement( ) ";
const FORMATTED: &str = "statement();\n";
const FIX_BEFORE: &str = "(1 >= -0)";
-const FIX_AFTER: &str = "(1 >= 0)";
+const FIX_AFTER: &str = "1 >= 0;\n";
const UNORGANIZED: &str = r#"import * as something from "../something";
import { lorem, foom, bar } from "foo";"#;
diff --git a/crates/biome_cli/tests/cases/overrides_linter.rs b/crates/biome_cli/tests/cases/overrides_linter.rs
index a4cce7525008..c5873782b05b 100644
--- a/crates/biome_cli/tests/cases/overrides_linter.rs
+++ b/crates/biome_cli/tests/cases/overrides_linter.rs
@@ -6,13 +6,13 @@ use bpaf::Args;
use camino::Utf8Path;
const FIX_BEFORE: &str = "(1 >= -0)";
-const FIX_AFTER: &str = "(1 >= 0)";
+const FIX_AFTER: &str = "1 >= 0;\n";
-const DEBUGGER_BEFORE: &str = "debugger";
+const DEBUGGER_BEFORE: &str = "debugger;\n";
const DEBUGGER_AFTER: &str = "";
const SIMPLE_NUMBERS_BEFORE: &str = "({ 0x1: 1 });";
-const SIMPLE_NUMBERS_AFTER: &str = "({ 1: 1 });";
+const SIMPLE_NUMBERS_AFTER: &str = "({ 1: 1 });\n";
#[test]
fn does_handle_included_file_and_disable_linter() {
diff --git a/crates/biome_cli/tests/cases/suppressions.rs b/crates/biome_cli/tests/cases/suppressions.rs
index 064c15645dc5..7d56824870ff 100644
--- a/crates/biome_cli/tests/cases/suppressions.rs
+++ b/crates/biome_cli/tests/cases/suppressions.rs
@@ -5,12 +5,12 @@ use biome_fs::{FileSystemExt, MemoryFileSystem};
use bpaf::Args;
use camino::Utf8Path;
-const SUPPRESS_BEFORE: &str = "(1 >= -0)";
+const SUPPRESS_BEFORE: &str = "1 >= -0;\n";
const SUPPRESS_AFTER: &str =
- "// biome-ignore lint/suspicious/noCompareNegZero: ignored using `--suppress`\n(1 >= -0)";
+ "// biome-ignore lint/suspicious/noCompareNegZero: ignored using `--suppress`\n1 >= -0;\n";
const SUPPRESS_WITH_REASON: &str =
- "// biome-ignore lint/suspicious/noCompareNegZero: We love Biome\n(1 >= -0)";
+ "// biome-ignore lint/suspicious/noCompareNegZero: We love Biome\n1 >= -0;\n";
#[test]
fn ok() {
diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs
index cd7205495063..20400eaf1ecd 100644
--- a/crates/biome_cli/tests/commands/lint.rs
+++ b/crates/biome_cli/tests/commands/lint.rs
@@ -38,7 +38,7 @@ const NO_DEBUGGER: &str = "debugger;";
const NEW_SYMBOL: &str = "new Symbol(\"\");";
const FIX_BEFORE: &str = "(1 >= -0)";
-const FIX_AFTER: &str = "(1 >= 0)";
+const FIX_AFTER: &str = "1 >= 0;\n";
const APPLY_SUGGESTED_BEFORE: &str = "let a = 4;
debugger;
@@ -306,7 +306,7 @@ function _f() { arguments; }
let expected = "const a = 4;
console.log(a);
-function _f() { arguments; }
+function _f() {\n\targuments;\n}
";
let test1 = Utf8Path::new("test1.js");
@@ -516,7 +516,7 @@ fn should_disable_a_rule_group() {
.read_to_string(&mut buffer)
.unwrap();
- assert_eq!(buffer, "(1 >= -0)");
+ assert_eq!(buffer, "1 >= -0;\n");
assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
@@ -3593,7 +3593,7 @@ function _f() { arguments; }
let expected = "const a = 4;
console.log(a);
-function _f() { arguments; }
+function _f() {\n\targuments;\n}
";
let test1 = Utf8Path::new("test1.js");
fs.insert(test1.into(), source.as_bytes());
diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/full_support.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/full_support.snap
index e58a15f5c9a2..0138e4ddf013 100644
--- a/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/full_support.snap
+++ b/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/full_support.snap
@@ -57,15 +57,15 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
# Emitted Messages
```block
-file.astro:16:20 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+file.astro:17:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Generic font family missing.
- 15 │
- 18 │
+ 16 │
- 14 │
+ 15 │
- 19 │
+ 20 │
- 14 │
+ 15 │
- 19 │
+ 20 │
- │ ^^^^^^^^^^^^^^^^
- 8 │
+ 5 │
i background-color is already defined here.
- 6 │
- > 7 │
- │ ^^^^^^^^^^^^^^^^
- 8 │
+ 4 │
+ 5 │