diff --git a/.changeset/vast-donuts-rescue.md b/.changeset/vast-donuts-rescue.md new file mode 100644 index 000000000000..09cd4030e408 --- /dev/null +++ b/.changeset/vast-donuts-rescue.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": patch +--- + +`indentScriptAndStyle` no longer indents the frontmatter 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 4010616d591a..5bccbd4ba2d3 100644 --- a/crates/biome_cli/tests/cases/handle_astro_files.rs +++ b/crates/biome_cli/tests/cases/handle_astro_files.rs @@ -667,3 +667,51 @@ fn format_astro_with_typescript_script_tag() { result, )); } + +#[test] +fn dont_indent_frontmatter() { + let fs = MemoryFileSystem::default(); + let mut console = BufferConsole::default(); + + fs.insert( + "biome.json".into(), + r#"{ "html": { "formatter": {"enabled": true, "indentScriptAndStyle": true}, "linter": {"enabled": true}, "experimentalFullSupportEnabled": true } }"#.as_bytes(), + ); + + let astro_file_path = Utf8Path::new("file.astro"); + fs.insert( + astro_file_path.into(), + r#"--- +import Foo from "./Foo.astro" +const bar = 123 +if (bar>1) {console.log(bar+1)} +--- +{bar} + + + + +"# + .as_bytes(), + ); + + let (fs, result) = run_cli( + fs, + &mut console, + Args::from(["format", "--write", astro_file_path.as_str()].as_slice()), + ); + + assert!(result.is_ok(), "run_cli returned {result:?}"); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "dont_indent_frontmatter", + fs, + console, + result, + )); +} diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/dont_indent_frontmatter.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/dont_indent_frontmatter.snap new file mode 100644 index 000000000000..72223e408f13 --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/dont_indent_frontmatter.snap @@ -0,0 +1,50 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: redactor(content) +--- +## `biome.json` + +```json +{ + "html": { + "formatter": { "enabled": true, "indentScriptAndStyle": true }, + "linter": { "enabled": true }, + "experimentalFullSupportEnabled": true + } +} +``` + +## `file.astro` + +```astro +--- +import Foo from "./Foo.astro"; +const bar = 123; +if (bar > 1) { + console.log(bar + 1); +} +--- +{bar} + + + + + +``` + +# Emitted Messages + +```block +Formatted 1 file in