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
5 changes: 5 additions & 0 deletions .changeset/small-sides-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed [#7860](https://github.com/biomejs/biome/issues/7860): The css parser, with `tailwindDirectives` enabled, will now accept `@plugin` options.
45 changes: 34 additions & 11 deletions crates/biome_css_factory/src/generated/node_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion crates/biome_css_factory/src/generated/syntax_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ impl FormatNodeRule<TwPluginAtRule> for FormatTwPluginAtRule {
let TwPluginAtRuleFields {
plugin_token,
name,
block,
semicolon_token,
} = node.as_fields();

write!(
f,
[
plugin_token.format(),
space(),
name.format(),
semicolon_token.format()
]
)
write!(f, [plugin_token.format(), space(), name.format()])?;
if let Some(block) = block {
write!(f, [space(), block.format()])?;
if let Some(semicolon_token) = semicolon_token {
write!(f, [format_removed(&semicolon_token)])?;
}
} else {
write!(f, [semicolon_token.format()])?;
}

Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@plugin "my-plugin" ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: css/tailwind/plugin-no-options.css
---
# Input

```css
@plugin "my-plugin" ;

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
-----

```css
@plugin "my-plugin";
```

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
-----

```css
@plugin "my-plugin";
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@plugin "my-plugin" {
debug: false;
threshold:0.5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: css/tailwind/plugin-with-options.css
---
# Input

```css
@plugin "my-plugin" {
debug: false;
threshold:0.5;
}

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
-----

```css
@plugin "my-plugin" {
debug: false;
threshold: 0.5;
}
```

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
-----

```css
@plugin "my-plugin" {
debug: false;
threshold: 0.5;
}
```
14 changes: 12 additions & 2 deletions crates/biome_css_parser/src/syntax/at_rule/tailwind.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::lexer::CssLexContext;
use crate::parser::CssParser;
use crate::syntax::block::{parse_declaration_or_rule_list_block, parse_rule_block};
use crate::syntax::block::{
parse_declaration_block, parse_declaration_or_rule_list_block, parse_rule_block,
};
use crate::syntax::parse_error::{expected_identifier, expected_selector, expected_string};
use crate::syntax::selector::parse_selector;
use crate::syntax::{is_at_identifier, parse_identifier, parse_regular_identifier, parse_string};
Expand Down Expand Up @@ -194,6 +196,11 @@ pub(crate) fn parse_config_at_rule(p: &mut CssParser) -> ParsedSyntax {
}

// @plugin "@tailwindcss/typography";
// OR
// @plugin "my-plugin" {
// debug: false;
// threshold: 0.5;
// }
pub(crate) fn parse_plugin_at_rule(p: &mut CssParser) -> ParsedSyntax {
if !p.at(T![plugin]) {
return Absent;
Expand All @@ -202,7 +209,10 @@ pub(crate) fn parse_plugin_at_rule(p: &mut CssParser) -> ParsedSyntax {
let m = p.start();
p.bump(T![plugin]);
parse_string(p).or_add_diagnostic(p, expected_string);
p.expect(T![;]);
if !p.eat(T![;]) {
parse_declaration_block(p);
p.eat(T![;]);
}

Present(m.complete(p, TW_PLUGIN_AT_RULE))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@plugin "my-plugin" {
.some-selector > * {
primary: "blue";
secondary: "green";
}
}

/* Error: `@plugin` can only contain declarations. */
Loading
Loading