diff --git a/.changeset/warm-plugins-offset.md b/.changeset/warm-plugins-offset.md new file mode 100644 index 000000000000..570ab66125e1 --- /dev/null +++ b/.changeset/warm-plugins-offset.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": patch +--- + +Fixed plugin diagnostics showing incorrect line numbers in Vue, Astro, and Svelte files. Plugin diagnostics now correctly account for the template/frontmatter offset, pointing to the right location in the ` +"#, + ); + + let (fs, result) = + run_cli_with_server_workspace(fs, &mut console, Args::from(["lint", file_path].as_slice())); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "check_plugin_diagnostic_offset_in_vue_file", + fs, + console, + result, + )); +} + #[test] fn doesnt_check_file_when_assist_is_disabled() { let fs = MemoryFileSystem::default(); diff --git a/crates/biome_cli/tests/snapshots/main_commands_check/check_plugin_diagnostic_offset_in_vue_file.snap b/crates/biome_cli/tests/snapshots/main_commands_check/check_plugin_diagnostic_offset_in_vue_file.snap new file mode 100644 index 000000000000..ed01b178acac --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_commands_check/check_plugin_diagnostic_offset_in_vue_file.snap @@ -0,0 +1,110 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +assertion_line: 432 +expression: redactor(content) +--- +## `biome.json` + +```json +{ + "overrides": [ + { + "includes": ["**/*.vue"], + "plugins": ["noFoo.grit"] + } + ] +} +``` + +## `file.vue` + +```vue + + + + +``` + +## `noFoo.grit` + +```grit +language js; + +JsIdentifierBinding() as $name where { + $name <: r"^foo$", + register_diagnostic( + span = $name, + message = "Avoid using 'foo' as a variable name.", + severity = "error" + ) +} + +``` + +# Termination Message + +```block +lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Some errors were emitted while running checks. + + + +``` + +# Emitted Messages + +```block +file.vue:15:7 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This variable foo is unused. + + 14 │ + 17 │ + + i Unused variables are often the result of typos, incomplete refactors, or other sources of bugs. + + i Unsafe fix: If this is intentional, prepend foo with an underscore. + + 1 │ - const·foo·=·'bad' + 1 │ + const·_foo·=·'bad' + 2 2 │ + + +``` + +```block +file.vue:15:7 plugin ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Avoid using 'foo' as a variable name. + + 14 │ + 17 │ + + +``` + +```block +Checked 1 file in