-
-
Notifications
You must be signed in to change notification settings - Fork 760
fix(parse/css): allow @plugin to accept options
#7866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: d585314 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
02420ba to
1c010b4
Compare
WalkthroughThis change updates the Tailwind Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (12)
📒 Files selected for processing (12)
🚧 Files skipped from review as they are similar to previous changes (7)
🧰 Additional context used📓 Path-based instructions (5).changeset/*.md📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
crates/biome_*/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.rs📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
xtask/codegen/*.ungram📄 CodeRabbit inference engine (CLAUDE.md)
Files:
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)crates/biome_css_formatter/src/tailwind/statements/plugin_at_rule.rs (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
🔇 Additional comments (6)
Comment |
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
CodSpeed Performance ReportMerging #7866 will not alter performanceComparing Summary
Footnotes
|
ematipico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not forget to add failing test cases for classic CSS
|
There's already a test for flagging I know it technically doesn't have options present, but I feel like we already cover all the behavior. |
1c010b4 to
f5d68f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options-2.css (1)
1-8: Negative case looks rightCatches rules inside
@plugin, which should be declarations-only. Consider adding another invalid case with a nested at-rule (e.g.,@media {}) inside the plugin block to cover both branches.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (12)
crates/biome_css_factory/src/generated/node_factory.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_factory/src/generated/syntax_factory.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_formatter/tests/specs/css/tailwind/plugin-no-options.css.snapis excluded by!**/*.snapand included by**crates/biome_css_formatter/tests/specs/css/tailwind/plugin-with-options.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options-2.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/tailwind/plugin-with-options-2.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/tailwind/plugin-with-options.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/tailwind/plugin.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/tailwind/shadcn-default.css.snapis excluded by!**/*.snapand included by**crates/biome_css_syntax/src/generated/nodes.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_syntax/src/generated/nodes_mut.rsis excluded by!**/generated/**,!**/generated/**and included by**
📒 Files selected for processing (12)
.changeset/small-sides-teach.md(1 hunks)crates/biome_css_formatter/src/tailwind/statements/plugin_at_rule.rs(1 hunks)crates/biome_css_formatter/tests/specs/css/tailwind/plugin-no-options.css(1 hunks)crates/biome_css_formatter/tests/specs/css/tailwind/plugin-with-options.css(1 hunks)crates/biome_css_parser/src/syntax/at_rule/tailwind.rs(3 hunks)crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options-2.css(1 hunks)crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options.css(1 hunks)crates/biome_css_parser/tests/css_test_suite/ok/tailwind/plugin-with-options-2.css(1 hunks)crates/biome_css_parser/tests/css_test_suite/ok/tailwind/plugin-with-options.css(1 hunks)crates/biome_grit_patterns/src/grit_target_language/css_target_language/constants.rs(1 hunks)crates/biome_parser/src/lib.rs(3 hunks)xtask/codegen/css.ungram(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- crates/biome_parser/src/lib.rs
- crates/biome_grit_patterns/src/grit_target_language/css_target_language/constants.rs
- crates/biome_css_formatter/src/tailwind/statements/plugin_at_rule.rs
- crates/biome_css_parser/tests/css_test_suite/ok/tailwind/plugin-with-options-2.css
- crates/biome_css_parser/tests/css_test_suite/ok/tailwind/plugin-with-options.css
- crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options.css
- .changeset/small-sides-teach.md
- crates/biome_css_formatter/tests/specs/css/tailwind/plugin-no-options.css
🧰 Additional context used
📓 Path-based instructions (5)
xtask/codegen/*.ungram
📄 CodeRabbit inference engine (CLAUDE.md)
Define and modify language grammars in .ungram files; ASTs are generated from these
Files:
xtask/codegen/css.ungram
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_css_formatter/tests/specs/css/tailwind/plugin-with-options.csscrates/biome_css_parser/src/syntax/at_rule/tailwind.rscrates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options-2.css
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_css_formatter/tests/specs/css/tailwind/plugin-with-options.csscrates/biome_css_parser/src/syntax/at_rule/tailwind.rscrates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options-2.css
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_css_formatter/tests/specs/css/tailwind/plugin-with-options.csscrates/biome_css_parser/tests/css_test_suite/error/tailwind/when-enabled/plugin-with-invalid-options-2.css
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Format Rust files before committing (e.g., viajust fwhich formats Rust)
Document rules, assists, and options with inline rustdoc in source
Files:
crates/biome_css_parser/src/syntax/at_rule/tailwind.rs
🧬 Code graph analysis (1)
crates/biome_css_parser/src/syntax/at_rule/tailwind.rs (1)
crates/biome_css_parser/src/syntax/block/declaration_or_rule_list_block.rs (1)
parse_declaration_or_rule_list_block(19-21)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Documentation
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: autofix
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Parser conformance
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_parser)
🔇 Additional comments (2)
crates/biome_css_formatter/tests/specs/css/tailwind/plugin-with-options.css (1)
1-4: Good fixture; please add two companions
- Add a variant with a trailing semicolon after the block to exercise the optional ';'.
- Add a variant using a custom property in options (e.g.,
--my-variable: "Favourite variable";) to mirror the issue report.crates/biome_css_parser/src/syntax/at_rule/tailwind.rs (1)
3-5: Import change is fine
parse_declaration_blockis the right choice to enforce declarations-only.
| 'plugin' | ||
| name: CssString | ||
| ';' | ||
| block: AnyCssDeclarationBlock? | ||
| ';'? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Tighten the TwPluginAtRule to disallow the “nothing after name” form
Current rule makes both block and ';' optional, inadvertently allowing @plugin "x" (no block, no semicolon). Require one of them, but still allow ';' after a block.
Apply this diff:
-TwPluginAtRule =
- 'plugin'
- name: CssString
- block: AnyCssDeclarationBlock?
- ';'?
+TwPluginAtRule =
+ 'plugin'
+ name: CssString
+ ( block: AnyCssDeclarationBlock ';'? | ';' )This matches the intended surface and the parser change above. Regenerate codegen after updating.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
xtask/codegen/css.ungram around lines 1974-1977: the TwPluginAtRule currently
makes both 'block' and ';' optional which permits a bare name with neither
(e.g., @plugin "x"); change the rule so that at least one of them is required —
i.e., allow either a block (optionally followed by a semicolon) or a standalone
semicolon, but disallow the case with neither; update the grammar accordingly
and then regenerate codegen after the change.
ematipico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a test case where the plugin block has semicolon
@plugin "my-plugin" {
debug: false;
threshold: 0.5;
};f5d68f7 to
d585314
Compare
Summary
The css parser is now able to parse
@plugindeclarations that have options blocks.fixes #7860
Test Plan
added parser and formatter tests
Docs