Skip to content

fix(css): skip useGenericFontNames rule inside @supports at-rules#8946

Closed
murataslan1 wants to merge 2 commits intobiomejs:mainfrom
murataslan1:fix/8845-use-generic-font-names-supports
Closed

fix(css): skip useGenericFontNames rule inside @supports at-rules#8946
murataslan1 wants to merge 2 commits intobiomejs:mainfrom
murataslan1:fix/8845-use-generic-font-names-supports

Conversation

@murataslan1
Copy link

Fixes #8845

Problem

The useGenericFontNames lint rule incorrectly triggered inside @supports queries, where font-family declarations are used to test feature support rather than to declare actual font usage.

Example that was incorrectly flagged:

@supports (font-family: Arial) { 
  a { color: red; } 
}

Solution

Added is_in_supports_at_rule() function to detect if a CssGenericProperty is inside a CssSupportsAtRule. The rule now skips validation when inside @supports blocks.

Testing

Added test cases in valid.css for both @supports condition and block scenarios.

Made with Cursor

Copilot AI review requested due to automatic review settings February 2, 2026 12:15
@changeset-bot
Copy link

changeset-bot bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: 7858350

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

This change updates the lint rule useGenericFontNames to skip processing declarations inside CSS @supports at-rules. It adds an AST helper is_in_supports_at_rule(node) that detects CssSupportsAtRule ancestry and returns early from the rule when a declaration is inside @supports. Tests were updated to include @supports cases and a selector fix; a changeset documents the behaviour change.

Possibly related PRs

Suggested reviewers

  • ematipico
  • siketyan
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: skipping the useGenericFontNames rule inside @supports at-rules, which is the core objective of this PR.
Description check ✅ Passed The description clearly explains the problem, solution, and testing approach, directly relating to the changeset and linked issue #8845.
Linked Issues check ✅ Passed The code changes successfully implement the requirement from #8845: the new is_in_supports_at_rule() function detects @supports blocks and the rule now skips validation within them, as requested.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the useGenericFontNames rule for @supports scenarios; no unrelated modifications are present.

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

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

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

This comment was marked as duplicate.

a { font-family: revert-layer } No newline at end of file
a { font-family: revert-layer }
@supports (font-family: Arial) { a { color: red; } }
@supports (display: grid) { a { font-family: Arial; } } No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

@supports (display: grid) { a { font-family: Arial; } }

This case should be flagged as invalid

Copy link
Author

Choose a reason for hiding this comment

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

Updated in 27e600b: declarations inside @supports blocks are checked, and this exact case is covered in invalid tests (@supports (display: grid) { a { font-family: Arial; } }).

@murataslan1

This comment has been minimized.

@murataslan1

This comment has been minimized.

@dyc3
Copy link
Contributor

dyc3 commented Feb 20, 2026

@murataslan1 1. my comments from my previous review have not been addressed, and 2. there's merge conflicts now

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 20, 2026

Merging this PR will improve performance by 10.79%

⚡ 9 improved benchmarks
✅ 20 untouched benchmarks
⏩ 127 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
foundation_11602414662825430680.css[uncached] 28 ms 26.2 ms +6.89%
bulma_5641719244145477318.css[uncached] 137.7 ms 124.6 ms +10.56%
bootstrap_18416142857265205439.css[uncached] 43.9 ms 41.2 ms +6.66%
tachyons_11778168428173736564.css[cached] 18.7 ms 17.6 ms +6.35%
bootstrap_18416142857265205439.css[cached] 40.4 ms 37.8 ms +6.93%
full_5814491140539129161.css[cached] 471.3 ms 425.4 ms +10.79%
foundation_11602414662825430680.css[cached] 26.3 ms 24.5 ms +7.28%
bulma_5641719244145477318.css[cached] 129.2 ms 117.1 ms +10.29%
full_5814491140539129161.css[uncached] 488.2 ms 446.8 ms +9.27%

Comparing murataslan1:fix/8845-use-generic-font-names-supports (73a2b53) with main (a794cd9)2

Open in CodSpeed

Footnotes

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

  2. No successful run was found on main (a08d66d) during the generation of this report, so a794cd9 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

murataslan1 and others added 2 commits February 21, 2026 07:41
…#8845)

Declarations inside @supports (condition or block) are used to test
feature support, not to declare actual font usage. Skip the
useGenericFontNames rule for font-family/font inside @supports.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@murataslan1 murataslan1 force-pushed the fix/8845-use-generic-font-names-supports branch from 73a2b53 to 7858350 Compare February 21, 2026 05:06
@murataslan1
Copy link
Author

@dyc3 Follow-up applied on branch fix/8845-use-generic-font-names-supports: your previous review point about @supports (display: grid) { a { font-family: Arial; } } is now covered as invalid, and the branch is rebased on current main (no merge conflict with main anymore). Please re-check when convenient.

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.

Your pr isn't fixing anything.....

Comment on lines -2 to -30
a { font-family: "Lucida Grande", "Arial", sans-serif; }
a { font: 1em "Lucida Grande", 'Arial', sans-serif; }
a { font: 1em "Lucida Grande", 'Arial', "sans-serif", sans-serif; }
a { font-family: Times, serif; }
b { font-family: inherit; }
b { font-family: inherit; }
b { font-family: initial; }
b { font-family: unset; }
b { font-family: serif; }
b { font-family: sans-serif; }
b { font-family: Courier, monospace; }
b { font: 1em/1.5 "Whatever Fanciness", cursive; }
a { font-family: Helvetica Neue, sans-serif, Apple Color Emoji; }
@font-face { font-family: Gentium; }
@FONT-FACE { font-family: Gentium; }
a { font: inherit; }
a { font: caption; }
a { font: icon; }
a { font: menu; }
a { font: message-box; }
a { font: small-caption; }
a { font: status-bar; }
a { font-family: var(--font); }
a { font-family: "Noto Serif", var(--serif); }
a { font-family: Arial, var(--fallback); }
a { font: 1em "Noto Serif", var(--serif); }
a { font: 14px/1.5 Arial, var(--fallback); }
a { font-family: revert }
a { font-family: revert-layer }
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change all of this? Revert

Comment on lines -1 to -7
a { font-family: Arial; }
a { font-family: 'Arial', "Lucida Grande", Arial; }
a { fOnT-fAmIlY: ' Lucida Grande '; }
a { font-family: Times; }
a { FONT: italic 300 16px/30px Arial, " Arial"; }
a { font: normal 14px/32px -apple-system, BlinkMacSystemFont; }
a { font: 1em Lucida Grande, Arial, "sans-serif" }
Copy link
Member

Choose a reason for hiding this comment

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

Revert. Just add new code at the end of the file

@ematipico ematipico closed this Feb 21, 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

4 participants