Skip to content

Commit 135f476

Browse files
author
subotac
authored
fix(lint/css): recognize Vue :deep() pseudo-class (#11184)
1 parent ed88b13 commit 135f476

5 files changed

Lines changed: 66 additions & 8 deletions

File tree

.changeset/big-paws-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#11176](https://github.com/biomejs/biome/issues/11176): `noUnknownPseudoClass` now recognizes Vue's `:deep()` pseudo-class inside `.vue` style blocks.

crates/biome_css_analyze/src/lint/correctness/no_unknown_pseudo_class.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ impl Rule for NoUnknownPseudoClass {
214214
if is_valid_class
215215
|| should_ignore(lower_name, ctx.options())
216216
|| file_source.is_css_modules() && is_css_module_pseudo_class(lower_name)
217+
// Vue uses `:deep()` to apply scoped styles to child components.
218+
// https://vuejs.org/api/sfc-css-features.html#deep-selectors
219+
|| file_source.is_vue_embedded() && lower_name == "deep"
217220
{
218221
None
219222
} else {

crates/biome_html_analyze/tests/spec_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) {
7878
if group == "specs" {
7979
panic!("the test file must be placed in the {group}/{rule}/<rule-name>/ directory");
8080
}
81-
if biome_html_analyze::METADATA
82-
.deref()
83-
.find_rule(group, rule)
84-
.is_none()
85-
{
86-
panic!("could not find rule {group}/{rule}");
87-
}
88-
8981
let rule_filter = RuleFilter::Rule(group, rule);
9082
let filter = AnalysisFilter {
9183
enabled_rules: Some(slice::from_ref(&rule_filter)),
@@ -99,6 +91,14 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) {
9991
.unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}"));
10092

10193
if let Some(scripts) = scripts_from_json(extension, &input_code) {
94+
if biome_html_analyze::METADATA
95+
.deref()
96+
.find_rule(group, rule)
97+
.is_none()
98+
{
99+
panic!("could not find rule {group}/{rule}");
100+
}
101+
102102
for script in scripts {
103103
analyze_and_snap(
104104
&mut snapshot,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- should not generate diagnostics -->
2+
3+
<template>
4+
<button>
5+
<span>123</span>
6+
</button>
7+
</template>
8+
9+
<script lang="ts" setup>
10+
11+
</script>
12+
13+
<style>
14+
button {
15+
height: 100px;
16+
17+
& :deep(span) {
18+
color: #fff
19+
}
20+
}
21+
</style>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
source: crates/biome_html_analyze/tests/spec_tests.rs
3+
expression: valid.vue
4+
---
5+
# Input
6+
```vue
7+
<!-- should not generate diagnostics -->
8+
9+
<template>
10+
<button>
11+
<span>123</span>
12+
</button>
13+
</template>
14+
15+
<script lang="ts" setup>
16+
17+
</script>
18+
19+
<style>
20+
button {
21+
height: 100px;
22+
23+
& :deep(span) {
24+
color: #fff
25+
}
26+
}
27+
</style>
28+
29+
```

0 commit comments

Comments
 (0)