Skip to content

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Oct 13, 2025

Summary

This adds a simple escape hatch for the noUnknownAtRules rule. This was brought up in #7223, and I thought it would be a good idea.

Test Plan

Added a test

Docs

updated the doc comment

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: 4ab6e2a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@biomejs/biome Minor
@biomejs/cli-win32-x64 Minor
@biomejs/cli-win32-arm64 Minor
@biomejs/cli-darwin-x64 Minor
@biomejs/cli-darwin-arm64 Minor
@biomejs/cli-linux-x64 Minor
@biomejs/cli-linux-arm64 Minor
@biomejs/cli-linux-x64-musl Minor
@biomejs/cli-linux-arm64-musl Minor
@biomejs/wasm-web Minor
@biomejs/wasm-bundler Minor
@biomejs/wasm-nodejs Minor
@biomejs/backend-jsonrpc Patch
@biomejs/js-api Major

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

@github-actions github-actions bot added A-Linter Area: linter L-CSS Language: CSS labels Oct 13, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

Walkthrough

Adds an ignore list to the CSS linter rule suspicious.noUnknownAtRules. Introduces a case-insensitive should_ignore(name, options) and updates NoUnknownAtRules::run to compute the at-rule name once, skip processing when the name matches ignore, and avoid recomputing the token text. Adds NoUnknownAtRulesOptions with a public ignore: Vec<String> field (skipped when empty). Adds tests and an options JSON demonstrating ignored custom at-rules (@custom-at-rule, @MyCustomRule, @another-custom-rule) and a changeset updating the package release notes.

Suggested reviewers

  • ematipico

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the primary change—adding an ignore option to the noUnknownAtRule rule—and follows conventional commit formatting, making it clear and specific for maintainers reviewing the history.
Description Check ✅ Passed The description outlines the motivation for the change, links to the related issue, and summarises the test plan and documentation update, all of which directly correspond to adding the ignore option to the rule.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dyc3/ignore-unknown-at-rules

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (1)

10-50: Consider documenting the ignore option.

The rule documentation explains the rule well but doesn't mention the new ignore option. Adding an example would help users discover this feature.

Consider adding a section like this after the existing examples:

 /// ```css
 /// @media (max-width: 960px) {
 ///   body {
 ///     font-size: 13px;
 ///   }
 /// }
 /// ```
+///
+/// ## Options
+///
+/// Allows ignoring specific at-rules by name (case-insensitive):
+///
+/// ```json
+/// {
+///   "linter": {
+///     "rules": {
+///       "suspicious": {
+///         "noUnknownAtRules": {
+///           "options": {
+///             "ignore": ["custom-at-rule", "my-framework-rule"]
+///           }
+///         }
+///       }
+///     }
+///   }
+/// }
+/// ```
 pub NoUnknownAtRules {
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d523500 and f2fc059.

⛔ Files ignored due to path filters (2)
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (4)
  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (2 hunks)
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css (1 hunks)
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.options.json (1 hunks)
  • crates/biome_rule_options/src/no_unknown_at_rules.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
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_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.options.json
  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.options.json
  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs
  • crates/biome_rule_options/src/no_unknown_at_rules.rs
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.options.json
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Before committing, format Rust and TOML files (e.g., via just f/just format)

Files:

  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs
  • crates/biome_rule_options/src/no_unknown_at_rules.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and options via inline rustdoc in Rust source

Files:

  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs
  • crates/biome_rule_options/src/no_unknown_at_rules.rs
🧠 Learnings (2)
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
PR: biomejs/biome#7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.

Applied to files:

  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.options.json
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/*.rs : Define per-rule options in biome_rule_options/lib/<rule>.rs with a dedicated options struct/enum (camelCase serde names, deny_unknown_fields, default) and derive Serialize/Deserialize/Deserializable (and schemars JsonSchema when schema feature is on)

Applied to files:

  • crates/biome_rule_options/src/no_unknown_at_rules.rs
🧬 Code graph analysis (2)
crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoUnknownAtRulesOptions (8558-8558)
crates/biome_rule_options/src/no_unknown_at_rules.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoUnknownAtRulesOptions (8558-8558)
⏰ 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). (10)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_css_parser)
  • 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: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
🔇 Additional comments (5)
crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.options.json (1)

1-15: LGTM!

The test configuration is well-structured and correctly specifies the ignore list for the custom at-rules used in the test file.

crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (2)

56-64: LGTM!

The case-insensitive comparison is appropriate for CSS at-rules. The logic is clear and correct.


83-93: Good optimisation!

Precomputing the name and reusing it avoids redundant work. The early return for ignored rules is clean.

crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css (1)

1-10: LGTM!

The test cases effectively demonstrate the ignore feature with various at-rule names and cases.

crates/biome_rule_options/src/no_unknown_at_rules.rs (1)

3-10: LGTM!

The options struct follows the established patterns with proper serde configuration. The skip_serializing_if attribute is appropriate for omitting empty ignore lists, and the documentation correctly notes case-insensitive matching.

Based on learnings

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 13, 2025

CodSpeed Performance Report

Merging #7745 will not alter performance

Comparing dyc3/ignore-unknown-at-rules (4ab6e2a) with next (d3aac63)

Summary

✅ 29 untouched
⏩ 111 skipped1

Footnotes

  1. 111 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two important things are missing:

  • changeset
  • docs must be updated to reflect the new option

@dyc3
Copy link
Contributor Author

dyc3 commented Oct 13, 2025

Oh yeah, whoops. I'll fix that up.

@dyc3 dyc3 force-pushed the dyc3/ignore-unknown-at-rules branch from bff2b1d to be2b0e2 Compare October 13, 2025 13:28
@dyc3 dyc3 force-pushed the dyc3/ignore-unknown-at-rules branch from 244ce72 to 50c6ff2 Compare October 13, 2025 13:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (1)

8-8: Include ignore in generated NoUnknownAtRulesOptions
The workspace.ts interface is auto-generated; adjust xtask/codegen to add the new ignore option.

🧹 Nitpick comments (1)
crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (1)

82-90: Consider using iterator combinators.

The function works correctly, but could be more concise:

-fn should_ignore(name: &str, options: &NoUnknownAtRulesOptions) -> bool {
-    for ignore_pattern in &options.ignore {
-        if name.eq_ignore_ascii_case(ignore_pattern) {
-            return true;
-        }
-    }
-    false
-}
+fn should_ignore(name: &str, options: &NoUnknownAtRulesOptions) -> bool {
+    options.ignore.iter().any(|p| name.eq_ignore_ascii_case(p))
+}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be2b0e2 and 50c6ff2.

⛔ Files ignored due to path filters (2)
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (5)
  • .changeset/breezy-suns-leave.md (1 hunks)
  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (3 hunks)
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css (1 hunks)
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.options.json (1 hunks)
  • crates/biome_rule_options/src/no_unknown_at_rules.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • .changeset/breezy-suns-leave.md
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.options.json
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid_with_ignore.css
  • crates/biome_rule_options/src/no_unknown_at_rules.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_analyze/src/lint/suspicious/no_unknown_at_rules.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Before committing, format Rust and TOML files (e.g., via just f/just format)

Files:

  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and options via inline rustdoc in Rust source

Files:

  • crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs
🧬 Code graph analysis (1)
crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoUnknownAtRulesOptions (8558-8558)
⏰ 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). (10)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_css_formatter)
🔇 Additional comments (2)
crates/biome_css_analyze/src/lint/suspicious/no_unknown_at_rules.rs (2)

35-67: Documentation looks solid.

The new options section clearly explains the ignore feature, including case-insensitive matching behaviour. The examples are helpful.


109-118: Well done—name computed once, no waste.

The refactoring to compute the name early and check the ignore list before constructing state is clean and efficient.

@dyc3
Copy link
Contributor Author

dyc3 commented Oct 13, 2025

The CI failure looks unrelated. The tests for biome_css_analyze pass on my machine.

@dyc3 dyc3 merged commit 6fcbc07 into next Oct 13, 2025
14 of 16 checks passed
@dyc3 dyc3 deleted the dyc3/ignore-unknown-at-rules branch October 13, 2025 14:41
@github-actions github-actions bot mentioned this pull request Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-CSS Language: CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants