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
55 changes: 54 additions & 1 deletion crates/biome_cli/tests/cases/handle_vue_files.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::run_cli;
use crate::snap_test::{SnapshotPayload, assert_cli_snapshot};
use biome_console::BufferConsole;
use biome_fs::MemoryFileSystem;
use biome_fs::{FileSystemExt, MemoryFileSystem};
use bpaf::Args;
use camino::Utf8Path;

Expand Down Expand Up @@ -1448,3 +1448,56 @@ import { mdiSquareOutline } from "@mdi/js";
result,
));
}

#[test]
fn suppress_does_not_add_comments_for_imports_used_in_templates() {
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 { mdiSquareOutline } from "@mdi/js";
</script>

<template>
<v-icon :icon="mdiSquareOutline" />
</template>
"#
.as_bytes(),
);

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

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

let mut buffer = String::new();
fs.open(file).unwrap().read_to_string(&mut buffer).unwrap();

// Verify no suppression comment was added - the import should not be flagged
// as unused since it's used in the template
assert!(
!buffer.contains("biome-ignore"),
"Suppress should not add comments for imports used in templates. File content:\n{}",
buffer
);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"suppress_does_not_add_comments_for_imports_used_in_templates",
fs,
console,
result,
));
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ expression: redactor(content)

```astro
---
import s from "src/utils";
import { sure } from "sure.js";
import z from "zod";

Expand Down Expand Up @@ -60,39 +61,39 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
# Emitted Messages

```block
file.astro:9:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.astro:10:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Provide a lang attribute when using the html element.

7 │ ---
8
> 9 │ <html>
8 │ ---
9
> 10 │ <html>
│ ^^^^^^
> 10 │ <head>
> 11 │ <title>Astro</title>
> 12 │ </head>
> 13 │ <body></body>
> 14 │ </html>
> 11 │ <head>
> 12 │ <title>Astro</title>
> 13 │ </head>
> 14 │ <body></body>
> 15 │ </html>
│ ^^^^^^^
15
16 │ <style>
16
17 │ <style>

i Setting a lang attribute on HTML document elements configures the language used by screen readers when no user default is specified.


```

```block
file.astro:18:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.astro:19:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Generic font family missing.

16 │ <style>
17 │ #id {
> 18 │ font-family: comic-sans;
17 │ <style>
18 │ #id {
> 19 │ font-family: comic-sans;
│ ^^^^^^^^^^
19 │ }
20 │ .class {
20 │ }
21 │ .class {

i Consider adding a generic font family as a fallback.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ expression: redactor(content)

```svelte
<script>
import s from "src/utils";
import { sure } from "sure.js";
import z from "zod";

Expand Down Expand Up @@ -60,39 +61,39 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
# Emitted Messages

```block
file.svelte:9:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.svelte:10:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Provide a lang attribute when using the html element.

7 │ </script>
8
> 9 │ <html>
8 │ </script>
9
> 10 │ <html>
│ ^^^^^^
> 10 │ <head>
> 11 │ <title>Svelte</title>
> 12 │ </head>
> 13 │ <body></body>
> 14 │ </html>
> 11 │ <head>
> 12 │ <title>Svelte</title>
> 13 │ </head>
> 14 │ <body></body>
> 15 │ </html>
│ ^^^^^^^
15
16 │ <style>
16
17 │ <style>

i Setting a lang attribute on HTML document elements configures the language used by screen readers when no user default is specified.


```

```block
file.svelte:18:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.svelte:19:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Generic font family missing.

16 │ <style>
17 │ #id {
> 18 │ font-family: comic-sans;
17 │ <style>
18 │ #id {
> 19 │ font-family: comic-sans;
│ ^^^^^^^^^^
19 │ }
20 │ .class {
20 │ }
21 │ .class {

i Consider adding a generic font family as a fallback.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ expression: redactor(content)

```svelte
<script lang="ts">
import s from "src/utils";
import { sure } from "sure.js";
import z from "zod";

Expand All @@ -27,7 +28,7 @@ interface Props {

let schema = z.object().optional();
schema + sure();
const _props: Props = { title: "Hello" };
const props: Props = { title: "Hello" };
</script>

<html>
Expand Down Expand Up @@ -62,39 +63,39 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
# Emitted Messages

```block
file.svelte:14:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.svelte:15:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Provide a lang attribute when using the html element.

12 │ </script>
13
> 14 │ <html>
13 │ </script>
14
> 15 │ <html>
│ ^^^^^^
> 15 │ <head>
> 16 │ <title>Svelte</title>
> 17 │ </head>
> 18 │ <body></body>
> 19 │ </html>
> 16 │ <head>
> 17 │ <title>Svelte</title>
> 18 │ </head>
> 19 │ <body></body>
> 20 │ </html>
│ ^^^^^^^
20
21 │ <style>
21
22 │ <style>

i Setting a lang attribute on HTML document elements configures the language used by screen readers when no user default is specified.


```

```block
file.svelte:23:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.svelte:24:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Generic font family missing.

21 │ <style>
22 │ #id {
> 23 │ font-family: comic-sans;
22 │ <style>
23 │ #id {
> 24 │ font-family: comic-sans;
│ ^^^^^^^^^^
24 │ }
25 │ .class {
25 │ }
26 │ .class {

i Consider adding a generic font family as a fallback.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ expression: redactor(content)

```vue
<script>
import s from "src/utils";
import { sure } from "sure.js";
import z from "zod";

Expand Down Expand Up @@ -63,39 +64,39 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
# Emitted Messages

```block
file.vue:9:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.vue:10:1 lint/a11y/useHtmlLang ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Provide a lang attribute when using the html element.

7 │ </script>
8
> 9 │ <html>
8 │ </script>
9
> 10 │ <html>
│ ^^^^^^
> 10 │ <head>
> 11 │ <title>Svelte</title>
> 12 │ </head>
> 13 │ <body></body>
> 14 │ </html>
> 11 │ <head>
> 12 │ <title>Svelte</title>
> 13 │ </head>
> 14 │ <body></body>
> 15 │ </html>
│ ^^^^^^^
15
16 │ <style>
16
17 │ <style>

i Setting a lang attribute on HTML document elements configures the language used by screen readers when no user default is specified.


```

```block
file.vue:18:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.vue:19:15 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Generic font family missing.

16 │ <style>
17 │ #id {
> 18 │ font-family: comic-sans;
17 │ <style>
18 │ #id {
> 19 │ font-family: comic-sans;
│ ^^^^^^^^^^
19 │ }
20 │ .class {
20 │ }
21 │ .class {

i Consider adding a generic font family as a fallback.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ expression: redactor(content)

```vue
<script lang="jsx">
import s from "src/utils";
import { sure } from "sure.js";
import z from "zod";

Expand Down
Loading