From 99c418978840de8fedaa114387111686344210b6 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Wed, 29 Jul 2026 14:28:15 -0700 Subject: [PATCH] Fix Google Fonts value suppression AI-assisted change. --- cli/lib/impeccable-config.mjs | 3 +++ skill/scripts/hook-lib.mjs | 3 +++ tests/hook.test.mjs | 6 ++++++ tests/lib/impeccable-config.test.js | 3 +++ 4 files changed, 15 insertions(+) diff --git a/cli/lib/impeccable-config.mjs b/cli/lib/impeccable-config.mjs index c45f74208..0c052d264 100644 --- a/cli/lib/impeccable-config.mjs +++ b/cli/lib/impeccable-config.mjs @@ -529,6 +529,9 @@ function extractFindingIgnoreValueRaw(finding, rule = normalizeIgnoreRule(findin const primary = text.match(/Primary font:\s*([^()\n;]+)/i); if (primary) return cleanIgnoreValueDisplay(primary[1]); + const googleLabel = text.match(/Google Fonts:\s*([^()\n;]+)/i); + if (googleLabel) return cleanIgnoreValueDisplay(googleLabel[1]); + const family = text.match(/font-family\s*:\s*["']?([^'",;\n]+)/i); if (family) return cleanIgnoreValueDisplay(family[1]); diff --git a/skill/scripts/hook-lib.mjs b/skill/scripts/hook-lib.mjs index 20059c747..65931f9e6 100644 --- a/skill/scripts/hook-lib.mjs +++ b/skill/scripts/hook-lib.mjs @@ -880,6 +880,9 @@ function extractFindingIgnoreValueRaw(finding, rule = normalizeIgnoreRule(findin const primary = text.match(/Primary font:\s*([^()\n;]+)/i); if (primary) return cleanIgnoreValueDisplay(primary[1]); + const googleLabel = text.match(/Google Fonts:\s*([^()\n;]+)/i); + if (googleLabel) return cleanIgnoreValueDisplay(googleLabel[1]); + const family = text.match(/font-family\s*:\s*["']?([^'",;\n]+)/i); if (family) return cleanIgnoreValueDisplay(family[1]); diff --git a/tests/hook.test.mjs b/tests/hook.test.mjs index 88db7bac5..08ca6d80e 100644 --- a/tests/hook.test.mjs +++ b/tests/hook.test.mjs @@ -470,6 +470,7 @@ describe('filterFindings()', () => { const findings = [ finding('overused-font', 1, { snippet: 'Primary font: Inter (86% of text)' }), finding('overused-font', 2, { snippet: 'Primary font: Roboto' }), + finding('overused-font', 5, { snippet: 'Google Fonts: space grotesk' }), finding('bounce-easing', 3, { snippet: 'animation: bounce-ball' }), finding('bounce-easing', 4, { snippet: 'animation: wobble-card' }), finding('side-tab', 3), @@ -478,6 +479,7 @@ describe('filterFindings()', () => { ignoreRules: [], ignoreValues: [ { rule: 'overused-font', value: 'inter' }, + { rule: 'overused-font', value: 'space grotesk' }, { rule: 'bounce-easing', value: 'bounce-ball' }, ], minSeverity: 'warning', @@ -574,6 +576,10 @@ describe('filterFindings()', () => { extractFindingIgnoreValue(finding('overused-font', 1, { snippet: 'https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400' })), 'plus jakarta sans', ); + assert.equal( + extractFindingIgnoreValue(finding('overused-font', 1, { snippet: 'Google Fonts: space grotesk' })), + 'space grotesk', + ); assert.equal(extractFindingIgnoreValue(finding('side-tab', 1)), ''); }); diff --git a/tests/lib/impeccable-config.test.js b/tests/lib/impeccable-config.test.js index 2fb00f28c..039fef2a3 100644 --- a/tests/lib/impeccable-config.test.js +++ b/tests/lib/impeccable-config.test.js @@ -182,6 +182,7 @@ describe('cli/lib/impeccable-config', () => { { antipattern: 'design-system-color', file: join(root, 'src', 'demo.css'), line: 3, ignoreValue: '#8b5cf6' }, { antipattern: 'design-system-color', file: join(root, 'src', 'real.css'), line: 4, ignoreValue: '#8b5cf6' }, { antipattern: 'design-system-font', file: join(root, 'src', 'demo.css'), line: 5, ignoreValue: 'Avenir Next' }, + { antipattern: 'overused-font', file: join(root, 'src', 'fonts.css'), line: 6, snippet: 'Google Fonts: space grotesk' }, ]; const filtered = filterDetectionFindings(findings, { ignoreRules: [], @@ -189,6 +190,7 @@ describe('cli/lib/impeccable-config', () => { { rule: 'overused-font', value: 'avenir next' }, { rule: 'design-system-color', value: '*', files: ['src/demo.css'] }, { rule: 'design-system-font', value: '*' }, + { rule: 'overused-font', value: 'space grotesk' }, ], }); @@ -236,6 +238,7 @@ describe('cli/lib/impeccable-config', () => { test('extractFindingIgnoreValue handles fonts, Google font URLs, and motion snippets', () => { expect(extractFindingIgnoreValue({ antipattern: 'overused-font', snippet: 'Primary font: Avenir Next (80% of text)' })).toBe('avenir next'); expect(extractFindingIgnoreValue({ antipattern: 'overused-font', snippet: 'https://fonts.googleapis.com/css2?family=Alumni+Sans:wght@700' })).toBe('alumni sans'); + expect(extractFindingIgnoreValue({ antipattern: 'overused-font', snippet: 'Google Fonts: space grotesk' })).toBe('space grotesk'); expect(extractFindingIgnoreValue({ antipattern: 'bounce-easing', snippet: 'animation: bounce-ball 1s infinite' })).toBe('bounce-ball'); });