fix(lint): ignore !important in font families (#2538)

This commit is contained in:
Miguel Ángel
2026-07-16 10:43:17 -04:00
committed by GitHub
parent f8c33cab72
commit b8a44e49c9
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -178,6 +178,14 @@ describe("font rules", () => {
expect(findings).toHaveLength(0);
});
it("does not treat !important as part of a generic font family", async () => {
const html = `<div data-composition-id="test" data-width="1920" data-height="1080">
<style>body { font-family: 'Inter', cursive !important; }</style>
</div>`;
const findings = await findByCode(html, "font_family_without_font_face");
expect(findings).toHaveLength(0);
});
it("reports multiple missing families in one finding", async () => {
const html = `<div data-composition-id="test" data-width="1920" data-height="1080">
<style>
+1
View File
@@ -65,6 +65,7 @@ function extractFontFaceFamilies(styles: Array<{ content: string }>): Set<string
function normalizeUsedFontName(part: string): string | null {
const name = part
.trim()
.replace(/\s*!important\s*$/i, "")
.replace(/^['"]|['"]$/g, "")
.trim()
.toLowerCase();