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
37 changes: 37 additions & 0 deletions crates/biome_cli/tests/cases/handle_vue_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,3 +1363,40 @@ fn fails_for_ts_grammar_when_lang_is_not_ts() {
result,
));
}

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

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

let file = Utf8Path::new("file.vue");
fs.insert(
file.into(),
r#"<script>
import { computed } from "vue";
</script>"#
.as_bytes(),
);

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

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

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"lint_vue_should_not_add_extra_newlines_in_embedded_snippet",
fs,
console,
result,
));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: redactor(content)
---
## `biome.json`

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

## `file.vue`

```vue
<script>
import { computed } from "vue";
</script>
```

# Emitted Messages

```block
Checked 1 file in <TIME>. No fixes applied.
```
2 changes: 1 addition & 1 deletion crates/biome_service/src/file_handlers/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ pub(crate) fn update_snippets(
let new_token = ident(&format!(
"{}{}{}",
leading_trivia,
snippet.new_code.as_str(),
snippet.new_code.trim(), // trim to avoid duplicating trivia
trailing_trivia
));
mutation.replace_token(value_token, new_token);
Expand Down
Loading