|
| 1 | +/* eslint-disable no-magic-numbers */ |
| 2 | +import { Audit, CategoryRef, Group } from '@code-pushup/models'; |
| 3 | + |
| 4 | +export const LIGHTHOUSE_OUTPUT_FILE_DEFAULT = 'lighthouse-report.json'; |
| 5 | +export const LIGHTHOUSE_PERFORMANCE_CORE_GROUP_SLUG = 'performance-core'; |
| 6 | + |
| 7 | +export const LIGHTHOUSE_REPORT_NAME = 'lighthouse-report.json'; |
| 8 | +export const PLUGIN_SLUG = 'lighthouse'; |
| 9 | + |
| 10 | +export const fcpSlug = 'first-contentful-paint'; |
| 11 | +export const siSlug = 'speed-index'; |
| 12 | +export const tbtSlug = 'total-blocking-time'; |
| 13 | +export const clsSlug = 'cumulative-layout-shift'; |
| 14 | +export const lcpSlug = 'largest-contentful-paint'; |
| 15 | +export const audits: Audit[] = [ |
| 16 | + { |
| 17 | + slug: fcpSlug, |
| 18 | + title: 'First Contentful Paint', |
| 19 | + description: |
| 20 | + 'First Contentful Paint marks the time at which the first text or image is painted. [Learn more about the First Contentful Paint metric](https://developer.chrome.com/docs/lighthouse/performance/first-contentful-paint/).', |
| 21 | + }, |
| 22 | + { |
| 23 | + slug: lcpSlug, |
| 24 | + title: 'Largest Contentful Paint', |
| 25 | + description: |
| 26 | + 'Largest Contentful Paint marks the time at which the largest text or image is painted. [Learn more about the Largest Contentful Paint metric](https://developer.chrome.com/docs/lighthouse/performance/lighthouse-largest-contentful-paint/)', |
| 27 | + }, |
| 28 | + { |
| 29 | + slug: siSlug, |
| 30 | + title: 'Speed Index', |
| 31 | + description: |
| 32 | + 'Speed Index shows how quickly the contents of a page are visibly populated. [Learn more about the Speed Index metric](https://developer.chrome.com/docs/lighthouse/performance/speed-index/).', |
| 33 | + }, |
| 34 | + { |
| 35 | + slug: tbtSlug, |
| 36 | + title: 'Total Blocking Time', |
| 37 | + description: |
| 38 | + 'Sum of all time periods between FCP and Time to Interactive, when task length exceeded 50ms, expressed in milliseconds. [Learn more about the Total Blocking Time metric](https://developer.chrome.com/docs/lighthouse/performance/lighthouse-total-blocking-time/).', |
| 39 | + }, |
| 40 | + { |
| 41 | + slug: clsSlug, |
| 42 | + title: 'Cumulative Layout Shift', |
| 43 | + description: |
| 44 | + 'Cumulative Layout Shift measures the movement of visible elements within the viewport. [Learn more about the Cumulative Layout Shift metric](https://web.dev/articles/cls).', |
| 45 | + }, |
| 46 | + { |
| 47 | + slug: 'server-response-time', |
| 48 | + title: 'Initial server response time was short', |
| 49 | + description: |
| 50 | + 'Keep the server response time for the main document short because all other requests depend on it. [Learn more about the Time to First Byte metric](https://developer.chrome.com/docs/lighthouse/performance/time-to-first-byte/).', |
| 51 | + }, |
| 52 | + { |
| 53 | + slug: 'interactive', |
| 54 | + title: 'Time to Interactive', |
| 55 | + description: |
| 56 | + 'Time to Interactive is the amount of time it takes for the page to become fully interactive. [Learn more about the Time to Interactive metric](https://developer.chrome.com/docs/lighthouse/performance/interactive/).', |
| 57 | + }, |
| 58 | +]; |
| 59 | + |
| 60 | +export const corePerfGroupRefs: CategoryRef[] = [ |
| 61 | + /** |
| 62 | + * Lighthouse audits in this group should apply to one of: |
| 63 | + * - be included in the [web vitals]() |
| 64 | + * - not have a significant impact on our runtime performance or bundle size. |
| 65 | + * - be network related [web vitals]() |
| 66 | + * - be measurable (especially for performance audits) or have clear pass/fail states. |
| 67 | + * - not use 3rd party APIs for completing the audit check. |
| 68 | + */ |
| 69 | + { |
| 70 | + type: 'group', |
| 71 | + slug: LIGHTHOUSE_PERFORMANCE_CORE_GROUP_SLUG, |
| 72 | + plugin: PLUGIN_SLUG, |
| 73 | + weight: 1, |
| 74 | + }, |
| 75 | +]; |
| 76 | +export const categoryCorePerfGroup: Group = { |
| 77 | + slug: LIGHTHOUSE_PERFORMANCE_CORE_GROUP_SLUG, |
| 78 | + title: 'performance-core', |
| 79 | + refs: [ |
| 80 | + // web vitals |
| 81 | + { |
| 82 | + slug: fcpSlug, |
| 83 | + weight: 10, |
| 84 | + }, |
| 85 | + { |
| 86 | + slug: lcpSlug, |
| 87 | + weight: 25, |
| 88 | + }, |
| 89 | + { |
| 90 | + slug: tbtSlug, |
| 91 | + weight: 30, |
| 92 | + }, |
| 93 | + { |
| 94 | + slug: clsSlug, |
| 95 | + weight: 25, |
| 96 | + }, |
| 97 | + { |
| 98 | + slug: siSlug, |
| 99 | + weight: 10, |
| 100 | + }, |
| 101 | + // others |
| 102 | + { |
| 103 | + slug: 'server-response-time', |
| 104 | + weight: 0, |
| 105 | + }, |
| 106 | + { |
| 107 | + slug: 'interactive', |
| 108 | + weight: 0, |
| 109 | + }, |
| 110 | + { |
| 111 | + slug: 'user-timings', |
| 112 | + weight: 0, |
| 113 | + }, |
| 114 | + ], |
| 115 | +}; |
| 116 | + |
| 117 | +export const categoryCorePerfGroup2: Group = { |
| 118 | + slug: LIGHTHOUSE_PERFORMANCE_CORE_GROUP_SLUG + 2, |
| 119 | + title: 'performance-core-2', |
| 120 | + refs: [ |
| 121 | + // web vitals |
| 122 | + { |
| 123 | + slug: 'first-contentful-paint', |
| 124 | + weight: 10, |
| 125 | + }, |
| 126 | + { |
| 127 | + slug: 'largest-contentful-paint', |
| 128 | + weight: 25, |
| 129 | + }, |
| 130 | + { |
| 131 | + slug: 'total-blocking-time', |
| 132 | + weight: 30, |
| 133 | + }, |
| 134 | + { |
| 135 | + slug: 'cumulative-layout-shift', |
| 136 | + weight: 25, |
| 137 | + }, |
| 138 | + { |
| 139 | + slug: 'speed-index', |
| 140 | + weight: 10, |
| 141 | + }, |
| 142 | + ], |
| 143 | +}; |
0 commit comments