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/soft-rules-feel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed #7848: The css parser with `tailwindDirectives` enabled will now correctly parse tailwind's source exclude syntax: `@source not "foo.css";`
39 changes: 30 additions & 9 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 @@ -7,18 +7,15 @@ impl FormatNodeRule<TwSourceAtRule> for FormatTwSourceAtRule {
fn fmt_fields(&self, node: &TwSourceAtRule, f: &mut CssFormatter) -> FormatResult<()> {
let TwSourceAtRuleFields {
source_token,
not_token,
path,
semicolon_token,
} = node.as_fields();

write!(
f,
[
source_token.format(),
space(),
path.format(),
semicolon_token.format()
]
)
write!(f, [source_token.format(), space()])?;
if let Some(not_token) = not_token {
write!(f, [not_token.format(), space()])?;
}
write!(f, [path.format(), semicolon_token.format()])
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"css": {
"parser": {
"tailwindDirectives": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@source not "../routes/utils/ds.tsx";
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/atrule/tailwind/source-not.css
---
# Input

```css
@source not "../routes/utils/ds.tsx";

```


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

# Outputs

## Output 1

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

```css
@source not "../routes/utils/ds.tsx";
```

## Output 1

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

```css
@source not "../routes/utils/ds.tsx";
```
3 changes: 3 additions & 0 deletions crates/biome_css_parser/src/syntax/at_rule/tailwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ pub(crate) fn parse_source_at_rule(p: &mut CssParser) -> ParsedSyntax {

let m = p.start();
p.bump(T![source]);
if p.at(T![not]) {
p.bump(T![not]);
}
parse_string(p).or_add_diagnostic(p, expected_string);
p.expect(T![;]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ CssRoot {
at_token: AT@281..284 "@" [Newline("\n"), Newline("\n")] [],
rule: TwSourceAtRule {
source_token: SOURCE_KW@284..291 "source" [] [Whitespace(" ")],
not_token: missing (optional),
path: CssString {
value_token: CSS_STRING_LITERAL@291..303 "\"./base.css\"" [] [],
},
Expand Down Expand Up @@ -480,9 +481,10 @@ CssRoot {
0: AT@281..284 "@" [Newline("\n"), Newline("\n")] []
1: TW_SOURCE_AT_RULE@284..304
0: SOURCE_KW@284..291 "source" [] [Whitespace(" ")]
1: CSS_STRING@291..303
1: (empty)
2: CSS_STRING@291..303
0: CSS_STRING_LITERAL@291..303 "\"./base.css\"" [] []
2: SEMICOLON@303..304 ";" [] []
3: SEMICOLON@303..304 ";" [] []
5: CSS_QUALIFIED_RULE@304..380
0: CSS_SELECTOR_LIST@304..315
0: CSS_COMPOUND_SELECTOR@304..315
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@source not "../routes/utils/ds.tsx";
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
source: crates/biome_css_parser/tests/spec_test.rs
expression: snapshot
---
## Input

```css
@source not "../routes/utils/ds.tsx";

```


## AST

```
CssRoot {
bom_token: missing (optional),
rules: CssRuleList [
CssAtRule {
at_token: AT@0..1 "@" [] [],
rule: TwSourceAtRule {
source_token: SOURCE_KW@1..8 "source" [] [Whitespace(" ")],
not_token: NOT_KW@8..12 "not" [] [Whitespace(" ")],
path: CssString {
value_token: CSS_STRING_LITERAL@12..36 "\"../routes/utils/ds.tsx\"" [] [],
},
semicolon_token: SEMICOLON@36..37 ";" [] [],
},
},
],
eof_token: EOF@37..38 "" [Newline("\n")] [],
}
```

## CST

```
0: CSS_ROOT@0..38
0: (empty)
1: CSS_RULE_LIST@0..37
0: CSS_AT_RULE@0..37
0: AT@0..1 "@" [] []
1: TW_SOURCE_AT_RULE@1..37
0: SOURCE_KW@1..8 "source" [] [Whitespace(" ")]
1: NOT_KW@8..12 "not" [] [Whitespace(" ")]
2: CSS_STRING@12..36
0: CSS_STRING_LITERAL@12..36 "\"../routes/utils/ds.tsx\"" [] []
3: SEMICOLON@36..37 ";" [] []
2: EOF@37..38 "" [Newline("\n")] []

```
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CssRoot {
at_token: AT@0..1 "@" [] [],
rule: TwSourceAtRule {
source_token: SOURCE_KW@1..8 "source" [] [Whitespace(" ")],
not_token: missing (optional),
path: CssString {
value_token: CSS_STRING_LITERAL@8..44 "\"../node_modules/@my-company/ui-lib\"" [] [],
},
Expand All @@ -41,9 +42,10 @@ CssRoot {
0: AT@0..1 "@" [] []
1: TW_SOURCE_AT_RULE@1..45
0: SOURCE_KW@1..8 "source" [] [Whitespace(" ")]
1: CSS_STRING@8..44
1: (empty)
2: CSS_STRING@8..44
0: CSS_STRING_LITERAL@8..44 "\"../node_modules/@my-company/ui-lib\"" [] []
2: SEMICOLON@44..45 ";" [] []
3: SEMICOLON@44..45 ";" [] []
2: EOF@45..46 "" [Newline("\n")] []

```
13 changes: 11 additions & 2 deletions crates/biome_css_syntax/src/generated/nodes.rs

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

10 changes: 8 additions & 2 deletions crates/biome_css_syntax/src/generated/nodes_mut.rs

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

1 change: 1 addition & 0 deletions xtask/codegen/css.ungram
Original file line number Diff line number Diff line change
Expand Up @@ -1941,6 +1941,7 @@ TwApplyClassList = CssIdentifier*
// @source "../node_modules/@my-company/ui-lib";
TwSourceAtRule =
'source'
'not'?
path: CssString
';'

Expand Down
Loading