fix(css): ignore @supports queries in useGenericFontNames rule#8848
Conversation
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 detectedLatest commit: 186f5ae 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 |
WalkthroughAdds a guard to the useGenericFontNames lint to skip diagnostics when a CssGenericProperty appears inside the condition of a CSS Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
crates/biome_css_analyze/src/lint/a11y/use_generic_font_names.rs
Outdated
Show resolved
Hide resolved
dyc3
left a comment
There was a problem hiding this comment.
Please use our PR template.
crates/biome_css_analyze/src/lint/a11y/use_generic_font_names.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
There was a problem hiding this comment.
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.
crates/biome_css_analyze/src/lint/a11y/use_generic_font_names.rs
Outdated
Show resolved
Hide resolved
|
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
|
Thanks for the review! Follow-ups applied:
Could you please re-review when you have time? |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
|
Pushed an update to address the review feedback:
Could you please re-review when you have a moment? |
|
Follow-up update (addressing review feedback):
Could you please re-review when you have a moment? |
There was a problem hiding this comment.
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.
crates/biome_css_analyze/src/lint/a11y/use_generic_font_names.rs
Outdated
Show resolved
Hide resolved
|
Addressed the review note: updated the rustdoc around to use a fenced code block for the example. Also verified locally with . |
|
Follow-up: updated the rustdoc around |
Summary
Fixes #8845 by making
lint/a11y/useGenericFontNamesignorefont/font-familydeclarations that appear in the@supports (...)condition (supports feature declarations), so feature-detection tokens like-apple-system-bodydon’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.mdAI 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_csscargo test -p biome_css_analyze --test spec_tests a11y::use_generic_font_names::invalid_cssDocs
N/A