fix(css): ignore font properties inside @supports rules in useGenericFontNames#8914
Conversation
…FontNames The useGenericFontNames rule now ignores font and font-family properties inside @supports rules, as these are used for feature detection rather than actual font-family declarations. Fixes biomejs#8845 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: f665652 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 logic to the useGenericFontNames CSS a11y rule to skip linting when a declaration is inside 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 172-178: The current is_in_supports_at_rule uses
ancestors().find(...) which only checks the first matching at-rule ancestor and
misses cases where `@supports` is higher up (e.g. `@supports` wrapping `@media`);
change the ancestor scan to test all ancestors instead of using find: call
ancestors().any(...) and inside the closure check n.kind() ==
CssSyntaxKind::CSS_AT_RULE, cast to CssAtRule, call rule().ok() and return true
when matches!(rule, AnyCssAtRule::CssSupportsAtRule(_)); update the logic in
is_in_supports_at_rule accordingly so any ancestor `@supports` is detected
(referencing is_in_supports_at_rule, CssSyntaxKind::CSS_AT_RULE, CssAtRule,
rule().ok(), AnyCssAtRule::CssSupportsAtRule).
crates/biome_css_analyze/src/lint/a11y/use_generic_font_names.rs
Outdated
Show resolved
Hide resolved
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
The previous implementation using ancestors().find() only checked the first matching at-rule ancestor. This missed cases where @supports wraps other at-rules like @media: @supports (font: -apple-system-body) { @media screen { a { font-family: -apple-system; } } } Changed to use ancestors().any() to check all ancestors for @supports. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Closing this PR — I opened too many contributions across projects and need to focus. Apologies for the noise. |
Summary
useGenericFontNamesrule whenfontorfont-familyproperties are used inside@supportsrules@supportsat-rule is used for feature detection (e.g.,@supports (font: -apple-system-body) {}) and should not be treated as an actual font-family declarationFixes #8845
Test plan
@supports (font: -apple-system-body) {}and@supports (font-family: -apple-system) {}to valid.csscargo test -p biome_css_analyze use_generic_font_namesAI Disclosure
This PR was written primarily by Claude Code.
🤖 Generated with Claude Code