Skip to content

fix(css): ignore @supports queries in useGenericFontNames rule#8848

Merged
ematipico merged 8 commits intobiomejs:mainfrom
LouisLau-art:fix/css-use-generic-font-names-in-supports
Feb 6, 2026
Merged

fix(css): ignore @supports queries in useGenericFontNames rule#8848
ematipico merged 8 commits intobiomejs:mainfrom
LouisLau-art:fix/css-use-generic-font-names-in-supports

Conversation

@LouisLau-art
Copy link
Contributor

@LouisLau-art LouisLau-art commented Jan 23, 2026

Summary

Fixes #8845 by making lint/a11y/useGenericFontNames ignore font / font-family declarations that appear in the @supports (...) condition (supports feature declarations), so feature-detection tokens like -apple-system-body don’t trigger a misleading a11y diagnostic.

This does not ignore style declarations inside the @supports { ... } block — those are still linted as usual.

Changeset: .changeset/quiet-ads-fix2.md

AI assistance: Yes (OpenAI Codex was used for editing and response drafting.)

Test Plan

  • cargo test -p biome_css_analyze --test spec_tests a11y::use_generic_font_names::valid_css
  • cargo test -p biome_css_analyze --test spec_tests a11y::use_generic_font_names::invalid_css

Docs

N/A

This fixes issue biomejs#8845 where the useGenericFontNames rule was incorrectly
triggering in @supports queries. The rule should not enforce generic font
family requirements within @supports rules since they are conditional
blocks for feature detection.

Co-authored-by: Qwen Code <qwen@tongyi.aliyun.com>

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

🦋 Changeset detected

Latest commit: 186f5ae

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

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

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 Jan 23, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

Adds a guard to the useGenericFontNames lint to skip diagnostics when a CssGenericProperty appears inside the condition of a CSS @supports feature declaration. Implements an is_in_supports_feature_declaration helper that walks ancestor nodes to detect CSS_SUPPORTS_FEATURE_DECLARATION, and the lint's run returns early when that helper is true. Tests were updated (fixing a selector and adding an @supports case) and a changeset recording the patch was added. No public API changes.

Possibly related PRs

Suggested reviewers

  • siketyan
  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: ignoring @supports queries in the useGenericFontNames CSS linting rule.
Description check ✅ Passed The description thoroughly explains the fix, distinguishing between ignoring feature declarations in @supports conditions versus style declarations inside the block, and includes test plan and changeset reference.
Linked Issues check ✅ Passed The changes fully address issue #8845 by preventing useGenericFontNames from triggering on font tokens used in @supports feature conditions, whilst preserving linting for declarations inside the block.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the objective: helper function for @supports detection, test updates with valid and invalid cases, and changeset documentation. No extraneous modifications present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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: 1

🤖 Fix all issues with AI agents
In `@crates/biome_css_analyze/src/lint/a11y/use_generic_font_names.rs`:
- Around line 166-173: The helper is_in_supports_at_rule currently only checks
the first ancestor that is an at‑rule (using find) so nested cases like
`@supports` { `@media` { ... } } are missed; update it to examine all ancestor
at‑rules by iterating/filtering all ancestors with kind() ==
CssSyntaxKind::CSS_AT_RULE, casting each to CssAtRule, retrieving rule().ok(),
and returning true if any of those rules matches
AnyCssAtRule::CssSupportsAtRule(_); reference the function
is_in_supports_at_rule and the types CssGenericProperty, CssAtRule, and
AnyCssAtRule when making the change.

dyc3
dyc3 previously requested changes Jan 23, 2026
Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Please use our PR template.

LouisLau-art and others added 2 commits January 24, 2026 08:56
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Changed from find() to filter() to catch nested @supports queries like @supports { @media { ... } }
- This addresses the review comment about missing nested cases

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
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: 1

🤖 Fix all issues with AI agents
In @.changeset/quiet-ads-fix2.md:
- Line 5: Update the changeset title wording for clarity: in
.changeset/quiet-ads-fix2.md replace the phrase "ignore `@supports` queries in
useGenericFontNames rule" with a smoother variant such as "ignore `@supports`
queries within useGenericFontNames rule" or "ignore `@supports` queries inside
useGenericFontNames rule" so the message reads grammatically fluent while
preserving the same intent and scope.

@LouisLau-art
Copy link
Contributor Author

Updated the PR body to follow the template (including AI assistance disclosure) and refined the changeset wording as suggested.

- Changed is_in_supports_at_rule to is_in_supports_feature_declaration
- Only ignores the condition part (e.g., font: -apple-system-body)
- Styles inside @supports blocks are still checked
- Simplified the function to use a single .any() call
@LouisLau-art
Copy link
Contributor Author

Thanks for the review!

Follow-ups applied:

  • Updated the PR body to match the template (incl. AI assistance disclosure).
  • Simplified the @supports detection to a single ancestors().any(...) check (addressing the redundant filtering concern).
  • Tweaked the changeset wording and added a @supports (font: ...) valid spec case.

Could you please re-review when you have time?

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 5, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing LouisLau-art:fix/css-use-generic-font-names-in-supports (186f5ae) with main (fd33f86)

Summary

✅ 29 untouched benchmarks
⏩ 126 skipped benchmarks1

Footnotes

  1. 126 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.

@LouisLau-art
Copy link
Contributor Author

Pushed an update to address the review feedback:

  • The rule now only ignores feature declarations (the condition), not declarations inside the block.
  • Added a regression case in to ensure is still flagged.
  • Updated the PR description to use the PR template + corrected the summary/test plan.

Could you please re-review when you have a moment?

@LouisLau-art
Copy link
Contributor Author

Follow-up update (addressing review feedback):

  • The rule now only ignores @supports (...) feature declarations (the condition), not declarations inside the @supports { ... } block.
  • Added a regression case in invalid.css to ensure @supports { a { font-family: Arial; } } is still flagged.
  • Updated the PR description to use the PR template + corrected the summary/test plan.

Could you please re-review when you have a moment?

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: 1

🤖 Fix all issues with AI agents
In `@crates/biome_css_analyze/src/lint/a11y/use_generic_font_names.rs`:
- Around line 167-176: Update the rustdoc comment examples around the
is_in_supports_feature_declaration function to use a fenced code block (triple
backticks) so they become proper doctests; replace the inline backtick example
text with a ```css fenced block containing the `@supports` example and any
necessary runnable assertions or comments so the doctest compiles and passes.
Ensure the narrative lines remain as comments or plain text inside the fenced
block and keep references to the `@supports` condition versus block behavior
intact.

@LouisLau-art
Copy link
Contributor Author

Addressed the review note: updated the rustdoc around to use a fenced code block for the example. Also verified locally with .

@LouisLau-art
Copy link
Contributor Author

Follow-up: updated the rustdoc around is_in_supports_feature_declaration to use a fenced code block for the @supports example. Also verified locally with cargo test -p biome_css_analyze.

@ematipico ematipico dismissed dyc3’s stale review February 6, 2026 08:46

Feedback addressed

@ematipico ematipico merged commit 2cba2b3 into biomejs:main Feb 6, 2026
18 checks passed
@github-actions github-actions bot mentioned this pull request Feb 6, 2026
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.

💅 useGenericFontNames triggers in the @supports query

3 participants