Skip to content

Commit ab88099

Browse files
ematipicodyc3
andauthored
feat(html): support CSS modules syntax and vue css syntax (#8399)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: dyc3 <[email protected]>
1 parent bf02ba6 commit ab88099

File tree

49 files changed

+1062
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1062
-425
lines changed

.changeset/angry-women-accept.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@biomejs/biome": minor
3+
---
4+
5+
The Biome CSS parser is now able to parse Vue SFC syntax such as `:slotted` and `:deep`. These pseudo functions are only correctly parsed when the CSS is defined inside `.vue` components. Otherwise, Biome will a emit a parse error.
6+
7+
This capability is only available when `experimentalFullHtmlSupportedEnabled` is set to `true`.

.changeset/odd-flies-nail.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"@biomejs/biome": minor
3+
---
4+
5+
Improved the CSS parser for CSS modules. Biome now automatically enables CSS modules parsing for `*.module.css` files.
6+
7+
If your codebase has only `*.module.css` files, you can remove the parser feature as follows, because now Biome does it for you:
8+
9+
```diff
10+
{
11+
"css": {
12+
"parser": {
13+
- "cssModules": true
14+
}
15+
}
16+
}
17+
```

.changeset/plenty-hornets-hide.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@biomejs/biome": minor
3+
---
4+
5+
Added support for parsing `:global` and `:local` inside `.astro`, `.svelte` and `.vue` files, in `<style>` portion of the file.
6+
7+
This capability is only available when `experimentalFullHtmlSupportedEnabled` is set to `true`.

crates/biome_analyze/src/context.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub struct RuleContext<'a, R: Rule> {
2222
jsx_runtime: Option<JsxRuntime>,
2323
jsx_factory: Option<&'a str>,
2424
jsx_fragment_factory: Option<&'a str>,
25-
css_modules: bool,
2625
}
2726

2827
impl<'a, R> RuleContext<'a, R>
@@ -43,7 +42,6 @@ where
4342
jsx_runtime: Option<JsxRuntime>,
4443
jsx_factory: Option<&'a str>,
4544
jsx_fragment_factory: Option<&'a str>,
46-
css_modules: bool,
4745
) -> Result<Self, Error> {
4846
let rule_key = RuleKey::rule::<R>();
4947
Ok(Self {
@@ -60,7 +58,6 @@ where
6058
jsx_runtime,
6159
jsx_factory,
6260
jsx_fragment_factory,
63-
css_modules,
6461
})
6562
}
6663

@@ -203,10 +200,6 @@ where
203200
self.preferred_indentation
204201
}
205202

206-
pub fn is_css_modules(&self) -> bool {
207-
self.css_modules
208-
}
209-
210203
/// Attempts to retrieve a service from the current context
211204
///
212205
/// ```no_test

crates/biome_analyze/src/options.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ pub struct AnalyzerConfiguration {
8282
/// The JSX fragment factory function identifier (e.g., "Fragment")
8383
/// Only applies when jsx_runtime is ReactClassic.
8484
jsx_fragment_factory: Option<Box<str>>,
85-
86-
/// Whether the CSS files contain CSS Modules
87-
css_modules: bool,
8885
}
8986

9087
impl AnalyzerConfiguration {
@@ -132,11 +129,6 @@ impl AnalyzerConfiguration {
132129
self.preferred_indentation = preferred_indentation;
133130
self
134131
}
135-
136-
pub fn with_css_modules(mut self, css_modules: bool) -> Self {
137-
self.css_modules = css_modules;
138-
self
139-
}
140132
}
141133

142134
/// A set of information useful to the analyzer infrastructure
@@ -230,10 +222,6 @@ impl AnalyzerOptions {
230222
pub fn preferred_indentation(&self) -> PreferredIndentation {
231223
self.configuration.preferred_indentation
232224
}
233-
234-
pub fn css_modules(&self) -> bool {
235-
self.configuration.css_modules
236-
}
237225
}
238226

239227
#[derive(Clone, Copy, Debug, Default)]

crates/biome_analyze/src/registry.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ impl<L: Language + Default> RegistryRule<L> {
408408
let jsx_runtime = params.options.jsx_runtime();
409409
let jsx_factory = params.options.jsx_factory();
410410
let jsx_fragment_factory = params.options.jsx_fragment_factory();
411-
let css_modules = params.options.css_modules();
412411
let options = params.options.rule_options::<R>().unwrap_or_default();
413412
let ctx = RuleContext::new(
414413
&query_result,
@@ -423,7 +422,6 @@ impl<L: Language + Default> RegistryRule<L> {
423422
jsx_runtime,
424423
jsx_factory,
425424
jsx_fragment_factory,
426-
css_modules,
427425
)?;
428426

429427
for result in R::run(&ctx) {

crates/biome_analyze/src/signals.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ where
372372
self.options.jsx_runtime(),
373373
self.options.jsx_factory(),
374374
self.options.jsx_fragment_factory(),
375-
self.options.css_modules(),
376375
)
377376
.ok()?;
378377

@@ -411,7 +410,6 @@ where
411410
self.options.jsx_runtime(),
412411
self.options.jsx_factory(),
413412
self.options.jsx_fragment_factory(),
414-
self.options.css_modules(),
415413
)
416414
.ok();
417415
let mut actions = Vec::new();
@@ -478,7 +476,6 @@ where
478476
self.options.jsx_runtime(),
479477
self.options.jsx_factory(),
480478
self.options.jsx_fragment_factory(),
481-
self.options.css_modules(),
482479
)
483480
.ok();
484481
if let Some(ctx) = ctx {

crates/biome_cli/tests/cases/handle_astro_files.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ schema + sure()
230230
231231
<style>
232232
#id { font-family: comic-sans } .class { background: red}
233+
:global(div) {
234+
color: red;
235+
}
233236
</style>
234237
"#
235238
.as_bytes(),

crates/biome_cli/tests/cases/handle_svelte_files.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ schema + sure()
239239
240240
<style>
241241
#id { font-family: comic-sans } .class { background: red}
242+
:global(div) {
243+
color: red;
244+
}
242245
</style>
243246
"#
244247
.as_bytes(),

crates/biome_cli/tests/cases/handle_vue_files.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,12 @@ schema + sure()
493493
494494
<style>
495495
#id { font-family: comic-sans } .class { background: red}
496+
:slotted(div) {
497+
color: red;
498+
}
499+
:global(div) {
500+
color: red;
501+
}
496502
</style>
497503
"#
498504
.as_bytes(),

0 commit comments

Comments
 (0)