diff --git a/Cargo.lock b/Cargo.lock index 0460aebe2e79..dccf1bd5a8c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1496,6 +1496,7 @@ dependencies = [ "biome_grit_parser", "biome_grit_patterns", "biome_grit_syntax", + "biome_html_factory", "biome_html_formatter", "biome_html_parser", "biome_html_syntax", diff --git a/crates/biome_cli/tests/cases/html.rs b/crates/biome_cli/tests/cases/html.rs index 8862ef350b1a..7b1d98b38f6f 100644 --- a/crates/biome_cli/tests/cases/html.rs +++ b/crates/biome_cli/tests/cases/html.rs @@ -237,6 +237,7 @@ fn should_pull_diagnostics_from_embedded_languages_when_linting() { fs.insert( html_file.into(), r#" + "# .as_bytes(), @@ -274,3 +275,59 @@ fn should_pull_diagnostics_from_embedded_languages_when_linting() { result, )); } + +#[test] +fn should_apply_fixes_to_embedded_languages() { + let fs = MemoryFileSystem::default(); + let mut console = BufferConsole::default(); + + let html_file = Utf8Path::new("file.html"); + fs.insert( + html_file.into(), + r#" + +"# + .as_bytes(), + ); + + fs.insert( + Utf8Path::new("biome.json").into(), + r#"{ + "html": { + "formatter": { + "enabled": true, + "indentScriptAndStyle": true + }, + "linter": { + "enabled": true + }, + "assist": { + "enabled": true + } + } +}"# + .as_bytes(), + ); + + let (fs, result) = run_cli( + fs, + &mut console, + Args::from(["check", "--write", "--unsafe", html_file.as_str()].as_slice()), + ); + + assert!(result.is_err(), "run_cli returned {result:?}"); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "should_apply_fixes_to_embedded_languages", + fs, + console, + result, + )); +} diff --git a/crates/biome_cli/tests/snapshots/main_cases_html/should_apply_fixes_to_embedded_languages.snap b/crates/biome_cli/tests/snapshots/main_cases_html/should_apply_fixes_to_embedded_languages.snap new file mode 100644 index 000000000000..3acbfa2f6b04 --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_cases_html/should_apply_fixes_to_embedded_languages.snap @@ -0,0 +1,79 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: redactor(content) +--- +## `biome.json` + +```json +{ + "html": { + "formatter": { + "enabled": true, + "indentScriptAndStyle": true + }, + "linter": { + "enabled": true + }, + "assist": { + "enabled": true + } + } +} +``` + +## `file.html` + +```html + + + +``` + +# Termination Message + +```block +check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Some errors were emitted while running checks. + + + +``` + +# Emitted Messages + +```block +file.html:7:48 lint/suspicious/noDuplicateProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Duplicate properties can lead to unexpected behavior and may override previous declarations unintentionally. + + 6 │ + > 7 │ + │ ^^^^^^^^^^^^^^^^ + 8 │ + + i background-color is already defined here. + + 6 │ + > 7 │ + │ ^^^^^^^^^^^^^^^^ + 8 │ + + i Remove or rename the duplicate property to ensure consistent styling. + + +``` + +```block +Checked 1 file in