fix(lint): match @font-face when a comment inside the block holds a brace#1538
Merged
Merged
Conversation
…race font_family_without_font_face (and system_font_will_alias) collect @font-face blocks with `@font-face\s*\{[^}]*\}`, which stops at the first `}`. A CSS comment inside the block that contains a brace — `@font-face { /* 400 } regular */ font-family: 'X'; ... }` — truncates the match before the font-family, so the family is never recorded as declared and a later `font-family: 'X'` usage is wrongly flagged as used without an @font-face. Strip CSS comments before scanning so a brace inside one cannot split a block. Refs heygen-com#1534
miguel-heygen
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
font_family_without_font_face(andsystem_font_will_alias) collect declared@font-facefamilies with@font-face\s*\{[^}]*\}.[^}]*stops at the first}, so a CSS comment inside the block that contains a brace truncates the matchbefore
font-family:is reached:The family is never recorded as declared, and a later literal
font-family: 'Noto Sans SC'is then reported as used without an@font-face—a blocking error since 0.6.109, where #1495 promoted this rule from warning to error.
Fix: strip CSS comments before scanning. In valid CSS the only source of a
}inside an
@font-faceblock is a comment, so this closes the gap. It's the sametechnique #1495 already applied to
scene_layer_missing_visibility_kill("stripJS comments before pattern matching") and
caption_transcript_parse_error("balanced-bracket scanner replaces non-greedy regex") — just never applied to the
font rules.
Honest note on #1534
I believe this is the cause of #1534, but I want to be upfront: I could not
reproduce it with a clean
@font-face, no matter how large/complex thesurrounding CSS was (tested 139-line blocks, 15
@keyframes, Fontsource-stylemulti-line faces, comments that mention
@font-face, two<style>blocks). Theonly thing that reproduces the exact error is a brace inside the
@font-faceblock — realistically a comment. The reporter says the
@font-faceis byte-identicalbetween the passing and failing cases; if so, the failing file most likely has an
inline comment in the block that was dropped when minimizing the repro.
@Johnson-Jia — could you share the exact failing
@font-faceblock (or the minimalHTML) verbatim? If it carries a comment with a
}inside, this fixes it; if not,I'd like to track down the remaining mechanism. Marked
Refs #1534rather thanFixesuntil that's confirmed.Verification
@font-face); confirmed itgoes red on
mainand green with this change.packages/core: full lint suite 191/191,tsc --noEmitclean, and thepre-commit gate (oxlint + oxfmt +
fallow audit) clean.