From 6844a07c33061fcacad71681c4bda3514fd799da Mon Sep 17 00:00:00 2001 From: Akshar Patel Date: Thu, 22 Oct 2026 16:05:38 -0400 Subject: [PATCH] fix(lint): accept final font-family descriptors without semicolons --- docs/reference/lint-rules.mdx | 2 ++ packages/lint/src/rules/fonts.test.ts | 14 ++++++++++++++ packages/lint/src/rules/fonts.ts | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/reference/lint-rules.mdx b/docs/reference/lint-rules.mdx index d198134be13..d99159a9156 100644 --- a/docs/reference/lint-rules.mdx +++ b/docs/reference/lint-rules.mdx @@ -730,6 +730,8 @@ Source: `packages/lint/src/rules/fonts.ts`. **Fix:** Declare each family with `@font-face` pointing at the captured `.woff2` files, or bundle the font under `capture/assets/fonts/`. +The declaration may use a quoted or unquoted family name. If `font-family` is the last descriptor in the block, its final semicolon is optional. + ### `system_font_will_alias` **Warning.** A system font family is used without a matching `@font-face`; in distributed rendering system-font capture is disabled, so the font is substituted at render time and text can reflow. Only reported when the linter runs with the `distributed: true` option (linting for distributed or Lambda renders); a local render captures the system font as designed, so it is not flagged there. diff --git a/packages/lint/src/rules/fonts.test.ts b/packages/lint/src/rules/fonts.test.ts index 6afa663bbe2..2deb5e4971d 100644 --- a/packages/lint/src/rules/fonts.test.ts +++ b/packages/lint/src/rules/fonts.test.ts @@ -119,6 +119,20 @@ describe("font rules", () => { expect(findings).toHaveLength(0); }); + it.each(["ProjectFont", "Project Font"])( + "recognizes an unquoted final font-family descriptor without a semicolon: %s", + async (family) => { + const html = `
+ +
`; + const findings = await findByCode(html, "font_family_without_font_face"); + expect(findings).toHaveLength(0); + }, + ); + it("does not flag a system font declared via @font-face src: local()", async () => { // Regression: two independent reports of this rule hard-erroring on OS // system fonts (Hiragino Sans, Microsoft YaHei) that have no downloadable diff --git a/packages/lint/src/rules/fonts.ts b/packages/lint/src/rules/fonts.ts index 062cf73841a..8c0f92c325c 100644 --- a/packages/lint/src/rules/fonts.ts +++ b/packages/lint/src/rules/fonts.ts @@ -44,7 +44,7 @@ function stripCssComments(css: string): string { function extractFontFaceFamilies(styles: Array<{ content: string }>): Set { const families = new Set(); const fontFaceRe = /@font-face\s*\{[^}]*\}/gi; - const familyRe = /font-family\s*:\s*(['"]?)([^;'"]+)\1/i; + const familyRe = /font-family\s*:\s*(['"]?)([^;}'"]+)\1/i; for (const style of styles) { const content = stripCssComments(style.content); let match: RegExpExecArray | null;