Skip to content

fix(lint): read actual font CSS declarations - #5221

Queued
user-github-me wants to merge 1 commit into
heygen-com:mainfrom
user-github-me:fix/lint-font-css-declaration-boundaries
Queued

user-github-me wants to merge 1 commit into
heygen-com:mainfrom
user-github-me:fix/lint-font-css-declaration-boundaries

Conversation

@user-github-me

@user-github-me user-github-me commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

The font rules scan raw CSS for font-family, so unused custom properties and content strings can cause false missing-font errors. Quoted fake font-face declarations can also hide real missing fonts. Font tokens that are referenced by font-family: var(--font-family) must still be checked.

Read actual font declarations and descriptors through PostCSS. Resolve references against custom properties declared in the supplied styles, following bounded alias chains and keeping custom-property names case sensitive. Ignore unused tokens, unresolved variables, and cycles. Reuse the resolution for distributed alias warnings and locate missing-font diagnostics at the declaration that uses the token. This is static token resolution; it does not evaluate the full CSS cascade.

Validation:

  • The original declaration-boundary regressions reproduce on main. Eight referenced-token checks fail on the earlier PR revision; all 55 font-rule cases and 856 lint tests pass with the revision.
  • All 103 CLI lint/check/validate tests pass.
  • Eleven probes compare source and built linter results, built CLI diagnostics, and real Chrome computed font families. Missing-font references, alias chains, case-sensitive names, declared faces, unused tokens, cycles, and unresolved references give the expected results with no browser errors.
  • Lint and CLI builds, lint typecheck, repository lint, formatting, reachability, comment checks, and full pre-commit checks pass. Fallow finds no new issues in the two changed files.

Windows CI passes on current head 6254873: the current Windows run succeeds in all four lanes, including studio-1. The earlier Puppeteer installation failure is superseded. All current checks pass or are intentionally skipped.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reading real declarations through PostCSS does fix the false error for unused --font-family tokens and content strings. But it also removes a detection that main has today. With :root { --font-family: "Brand Heading"; } h1 { font-family: var(--font-family); } and no @font-face, main reports the missing family and this branch reports nothing, even though the text will fall back at render. Could you resolve var(--x) references in font-family against custom properties declared in the same styles, or otherwise keep flagging tokens that are actually referenced? Please also add that case as a test.

— Rames

@user-github-me
user-github-me force-pushed the fix/lint-font-css-declaration-boundaries branch from f4eec4a to 6254873 Compare October 8, 2026 20:13

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My earlier blocking concern is resolved at this head. resolveUsedFontNames now resolves var(--x) against custom properties declared across the supplied style blocks, following aliases with a cycle and depth bound, and the exact case I raised (:root { --font-family: "Brand Heading"; } h1 { font-family: var(--font-family); }) is a test that expects one font_family_without_font_face finding. Unused tokens, content strings and quoted fake @font-face text stay quiet because only real PostCSS declarations are read. A block PostCSS cannot parse now contributes nothing to this rule, but that matches the other postcss-based lint rules, and css_parse_error reports that block separately. The branch still merges cleanly onto current main, and main has not fixed this another way.

— Rames

@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 24, 2026
@jrusso1020
jrusso1020 removed this pull request from the merge queue due to a manual request Oct 24, 2026
@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants