diff --git a/packages/lighthouse-config/src/index.ts b/packages/lighthouse-config/src/index.ts index 1d2ce1d306..214324ec29 100644 --- a/packages/lighthouse-config/src/index.ts +++ b/packages/lighthouse-config/src/index.ts @@ -16,49 +16,73 @@ const lhConfig = ({ urls, server, assertions = {} }: Params) => { ci: { collect: { url, - settings: { - formFactor: 'mobile', - throttling: { - rttMs: 150, - throughputKbps: 1638.4, - requestLatencyMs: 562.5, - downloadThroughputKbps: 1474.56, - uploadThroughputKbps: 675, - cpuSlowdownMultiplier: 4, - }, - throttlingMethod: 'simulate', - screenEmulation: { - mobile: true, - width: 360, - height: 640, - deviceScaleFactor: 2.625, - disabled: false, - }, - emulatedUserAgent: - 'Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4143.7 Mobile Safari/537.36 Chrome-Lighthouse', - skipAudits: ['is-on-https'], - }, }, assert: { preset: 'lighthouse:no-pwa', assertions: { + // Final Ligthouse score Budgets 'categories:accessibility': ['error', { minScore: 0.95 }], 'categories:best-practices': ['error', { minScore: 0.95 }], 'categories:performance': ['error', { minScore: 0.95 }], - 'categories:pwa': 'off', 'categories:seo': ['error', { minScore: 0.9 }], - 'cumulative-layout-shift': ['error', { maxNumericValue: 0.2 }], - 'first-contentful-paint': ['error', { maxNumericValue: 2000 }], - 'is-crawlable': 'off', // preview pages are not crawlable - 'largest-contentful-paint': ['error', { maxNumericValue: 3500 }], - 'max-potential-fid': ['error', { maxNumericValue: 300 }], + 'categories:pwa': 'off', + + // Lighthouse Metrics Budgets + // Minimal score for perf 90 on each metric + 'first-contentful-paint': ['error', { maxNumericValue: 1800 }], + 'speed-index': ['error', { maxNumericValue: 3387 }], + 'largest-contentful-paint': ['error', { maxNumericValue: 2500 }], + interactive: ['error', { maxNumericValue: 3785 }], 'total-blocking-time': ['error', { maxNumericValue: 200 }], + 'cumulative-layout-shift': ['error', { maxNumericValue: 0.1 }], + + // Number of Requests Budgets + 'resource-summary:font:count': ['error', { maxNumericValue: 3 }], + 'resource-summary:image:count': ['error', { maxNumericValue: 20 }], + 'resource-summary:script:count': ['error', { maxNumericValue: 15 }], + 'resource-summary:stylesheet:count': [ + 'error', + { maxNumericValue: 3 }, + ], + 'resource-summary:third-party:count': [ + 'error', + { maxNumericValue: 100 }, + ], + + // Resource sizes Budgets + // To learn where this 1024 comes from: https://github.com/GoogleChrome/lighthouse-ci/blob/fe181b61b20205dba5962c40094b1c90983f1c5e/packages/utils/src/budgets-converter.js#L49 + 'resource-summary:document:size': [ + 'error', + { maxNumericValue: 20 * 1024 }, + ], + 'resource-summary:font:size': [ + 'error', + { maxNumericValue: 70 * 1024 }, + ], + 'resource-summary:image:size': [ + 'error', + { maxNumericValue: 500 * 1024 }, + ], + 'resource-summary:script:size': [ + 'error', + { maxNumericValue: 200 * 1024 }, + ], + 'resource-summary:stylesheet:size': [ + 'error', + { maxNumericValue: 100 * 1024 }, + ], + 'resource-summary:third-party:size': [ + 'error', + { maxNumericValue: 500 * 1024 }, + ], + 'resource-summary:total:size': [ + 'error', + { maxNumericValue: 600 * 1024 }, + ], + + // Extra Lighthouse Assertion rules 'unused-javascript': ['error', { maxLength: 10 }], - 'uses-long-cache-ttl': 'off', - 'uses-rel-preconnect': 'warn', // somehow lighthouse ci can't find the dns-prefetch tags we are adding - 'uses-text-compression': ['warn', { maxLength: 1 }], - bypass: 'off', - interactive: ['error', { maxNumericValue: 3000 }], + ...assertions, }, },