From 73c9f0de5b4f3fa25a79cd39006a082be0c5d952 Mon Sep 17 00:00:00 2001 From: Philip Walton Date: Wed, 27 Dec 2023 12:49:29 -0800 Subject: [PATCH] Fix formating issues after eslint update --- .eslintrc | 22 ++------------------- src/attribution/onCLS.ts | 4 ++-- src/attribution/onFCP.ts | 4 ++-- src/attribution/onFID.ts | 4 ++-- src/attribution/onINP.ts | 4 ++-- src/attribution/onLCP.ts | 10 +++++----- src/attribution/onTTFB.ts | 10 +++++----- src/lib/bfcache.ts | 2 +- src/lib/bindReporter.ts | 4 ++-- src/lib/getNavigationEntry.ts | 2 +- src/lib/initMetric.ts | 4 ++-- src/lib/observe.ts | 6 +++--- src/lib/polyfills/firstInputPolyfill.ts | 2 +- src/onCLS.ts | 6 +++--- src/onFCP.ts | 4 ++-- src/onFID.ts | 14 ++++++------- src/onINP.ts | 10 +++++----- src/onLCP.ts | 6 +++--- src/onTTFB.ts | 4 ++-- test/e2e/onCLS-test.js | 10 +++++----- test/e2e/onFCP-test.js | 8 ++++---- test/e2e/onINP-test.js | 8 ++++---- test/e2e/onLCP-test.js | 18 ++++++++--------- test/e2e/onTTFB-test.js | 26 ++++++++++++------------- 24 files changed, 87 insertions(+), 105 deletions(-) diff --git a/.eslintrc b/.eslintrc index 93bf34fa..1ab87ef0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -25,16 +25,7 @@ }, "extends": ["eslint:recommended"], "rules": { - "comma-dangle": [ - "error", - { - "arrays": "always-multiline", - "objects": "always-multiline", - "imports": "always-multiline", - "exports": "always-multiline", - "functions": "never" - } - ], + "comma-dangle": ["error", "always-multiline"], "indent": ["error", 2], "no-invalid-this": "off", "max-len": [ @@ -65,16 +56,7 @@ "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/camelcase": "off", - "comma-dangle": [ - "error", - { - "arrays": "always-multiline", - "objects": "always-multiline", - "imports": "always-multiline", - "exports": "always-multiline", - "functions": "never" - } - ], + "comma-dangle": ["error", "always-multiline"], "indent": ["error", 2], "node/no-missing-import": "off", "node/no-unsupported-features/es-syntax": "off", diff --git a/src/attribution/onCLS.ts b/src/attribution/onCLS.ts index 6bc12302..453e25b6 100644 --- a/src/attribution/onCLS.ts +++ b/src/attribution/onCLS.ts @@ -78,13 +78,13 @@ const attributeCLS = (metric: CLSMetric): void => { */ export const onCLS = ( onReport: CLSReportCallbackWithAttribution, - opts?: ReportOpts + opts?: ReportOpts, ) => { unattributedOnCLS( ((metric: CLSMetricWithAttribution) => { attributeCLS(metric); onReport(metric); }) as CLSReportCallback, - opts + opts, ); }; diff --git a/src/attribution/onFCP.ts b/src/attribution/onFCP.ts index 48728cc7..f2257d21 100644 --- a/src/attribution/onFCP.ts +++ b/src/attribution/onFCP.ts @@ -61,13 +61,13 @@ const attributeFCP = (metric: FCPMetric): void => { */ export const onFCP = ( onReport: FCPReportCallbackWithAttribution, - opts?: ReportOpts + opts?: ReportOpts, ) => { unattributedOnFCP( ((metric: FCPMetricWithAttribution) => { attributeFCP(metric); onReport(metric); }) as FCPReportCallback, - opts + opts, ); }; diff --git a/src/attribution/onFID.ts b/src/attribution/onFID.ts index f239f6d2..138c92e6 100644 --- a/src/attribution/onFID.ts +++ b/src/attribution/onFID.ts @@ -47,13 +47,13 @@ const attributeFID = (metric: FIDMetric): void => { */ export const onFID = ( onReport: FIDReportCallbackWithAttribution, - opts?: ReportOpts + opts?: ReportOpts, ) => { unattributedOnFID( ((metric: FIDMetricWithAttribution) => { attributeFID(metric); onReport(metric); }) as FIDReportCallback, - opts + opts, ); }; diff --git a/src/attribution/onINP.ts b/src/attribution/onINP.ts index 9f53dea6..d787fc6c 100644 --- a/src/attribution/onINP.ts +++ b/src/attribution/onINP.ts @@ -79,13 +79,13 @@ const attributeINP = (metric: INPMetric): void => { */ export const onINP = ( onReport: INPReportCallbackWithAttribution, - opts?: ReportOpts + opts?: ReportOpts, ) => { unattributedOnINP( ((metric: INPMetricWithAttribution) => { attributeINP(metric); onReport(metric); }) as INPReportCallback, - opts + opts, ); }; diff --git a/src/attribution/onLCP.ts b/src/attribution/onLCP.ts index d16a7a30..fcea5625 100644 --- a/src/attribution/onLCP.ts +++ b/src/attribution/onLCP.ts @@ -47,15 +47,15 @@ const attributeLCP = (metric: LCPMetric) => { lcpResourceEntry ? (lcpResourceEntry.requestStart || lcpResourceEntry.startTime) - activationStart - : 0 + : 0, ); const lcpResponseEnd = Math.max( lcpRequestStart, - lcpResourceEntry ? lcpResourceEntry.responseEnd - activationStart : 0 + lcpResourceEntry ? lcpResourceEntry.responseEnd - activationStart : 0, ); const lcpRenderTime = Math.max( lcpResponseEnd, - lcpEntry ? lcpEntry.startTime - activationStart : 0 + lcpEntry ? lcpEntry.startTime - activationStart : 0, ); const attribution: LCPAttribution = { @@ -102,13 +102,13 @@ const attributeLCP = (metric: LCPMetric) => { */ export const onLCP = ( onReport: LCPReportCallbackWithAttribution, - opts?: ReportOpts + opts?: ReportOpts, ) => { unattributedOnLCP( ((metric: LCPMetricWithAttribution) => { attributeLCP(metric); onReport(metric); }) as LCPReportCallback, - opts + opts, ); }; diff --git a/src/attribution/onTTFB.ts b/src/attribution/onTTFB.ts index 031dd9ed..8228462a 100644 --- a/src/attribution/onTTFB.ts +++ b/src/attribution/onTTFB.ts @@ -30,15 +30,15 @@ const attributeTTFB = (metric: TTFBMetric): void => { const dnsStart = Math.max( navigationEntry.domainLookupStart - activationStart, - 0 + 0, ); const connectStart = Math.max( navigationEntry.connectStart - activationStart, - 0 + 0, ); const requestStart = Math.max( navigationEntry.requestStart - activationStart, - 0 + 0, ); (metric as TTFBMetricWithAttribution).attribution = { @@ -76,13 +76,13 @@ const attributeTTFB = (metric: TTFBMetric): void => { */ export const onTTFB = ( onReport: TTFBReportCallbackWithAttribution, - opts?: ReportOpts + opts?: ReportOpts, ) => { unattributedOnTTFB( ((metric: TTFBMetricWithAttribution) => { attributeTTFB(metric); onReport(metric); }) as TTFBReportCallback, - opts + opts, ); }; diff --git a/src/lib/bfcache.ts b/src/lib/bfcache.ts index cf81e8a0..647b7310 100644 --- a/src/lib/bfcache.ts +++ b/src/lib/bfcache.ts @@ -31,6 +31,6 @@ export const onBFCacheRestore = (cb: onBFCacheRestoreCallback) => { cb(event); } }, - true + true, ); }; diff --git a/src/lib/bindReporter.ts b/src/lib/bindReporter.ts index ee4e4c5f..fa73db3c 100644 --- a/src/lib/bindReporter.ts +++ b/src/lib/bindReporter.ts @@ -18,7 +18,7 @@ import {MetricType, MetricRatingThresholds} from '../types.js'; const getRating = ( value: number, - thresholds: MetricRatingThresholds + thresholds: MetricRatingThresholds, ): MetricType['rating'] => { if (value > thresholds[1]) { return 'poor'; @@ -33,7 +33,7 @@ export const bindReporter = ( callback: (metric: Extract) => void, metric: Extract, thresholds: MetricRatingThresholds, - reportAllChanges?: boolean + reportAllChanges?: boolean, ) => { let prevValue: number; let delta: number; diff --git a/src/lib/getNavigationEntry.ts b/src/lib/getNavigationEntry.ts index 5f8270ce..fa523bdf 100644 --- a/src/lib/getNavigationEntry.ts +++ b/src/lib/getNavigationEntry.ts @@ -32,7 +32,7 @@ const getNavigationEntryFromPerformanceTiming = navigationEntry[key] = Math.max( (timing[key as keyof PerformanceTiming] as number) - timing.navigationStart, - 0 + 0, ); } } diff --git a/src/lib/initMetric.ts b/src/lib/initMetric.ts index 6ea9a406..90618d81 100644 --- a/src/lib/initMetric.ts +++ b/src/lib/initMetric.ts @@ -22,7 +22,7 @@ import {MetricType} from '../types.js'; export const initMetric = ( name: MetricName, - value?: number + value?: number, ) => { const navEntry = getNavigationEntry(); let navigationType: MetricType['navigationType'] = 'navigate'; @@ -37,7 +37,7 @@ export const initMetric = ( } else if (navEntry.type) { navigationType = navEntry.type.replace( /_/g, - '-' + '-', ) as MetricType['navigationType']; } } diff --git a/src/lib/observe.ts b/src/lib/observe.ts index b092e2f3..fca60989 100644 --- a/src/lib/observe.ts +++ b/src/lib/observe.ts @@ -40,7 +40,7 @@ interface PerformanceEntryMap { export const observe = ( type: K, callback: (entries: PerformanceEntryMap[K]) => void, - opts?: PerformanceObserverInit + opts?: PerformanceObserverInit, ): PerformanceObserver | undefined => { try { if (PerformanceObserver.supportedEntryTypes.includes(type)) { @@ -58,8 +58,8 @@ export const observe = ( type, buffered: true, }, - opts || {} - ) as PerformanceObserverInit + opts || {}, + ) as PerformanceObserverInit, ); return po; } diff --git a/src/lib/polyfills/firstInputPolyfill.ts b/src/lib/polyfills/firstInputPolyfill.ts index 6ac0314c..804c4238 100644 --- a/src/lib/polyfills/firstInputPolyfill.ts +++ b/src/lib/polyfills/firstInputPolyfill.ts @@ -36,7 +36,7 @@ const startTimeStamp: Date = new Date(); * are known. */ export const firstInputPolyfill = ( - onFirstInput: FirstInputPolyfillCallback + onFirstInput: FirstInputPolyfillCallback, ) => { callbacks.push(onFirstInput); reportFirstInputDelayIfRecordedAndValid(); diff --git a/src/onCLS.ts b/src/onCLS.ts index 7c1a1dcd..ee369752 100644 --- a/src/onCLS.ts +++ b/src/onCLS.ts @@ -107,7 +107,7 @@ export const onCLS = (onReport: CLSReportCallback, opts?: ReportOpts) => { onReport, metric, CLSThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); onHidden(() => { @@ -124,7 +124,7 @@ export const onCLS = (onReport: CLSReportCallback, opts?: ReportOpts) => { onReport, metric, CLSThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); doubleRAF(() => report()); @@ -135,6 +135,6 @@ export const onCLS = (onReport: CLSReportCallback, opts?: ReportOpts) => { // `reportAllChanges` is true. setTimeout(report, 0); } - }) + }), ); }; diff --git a/src/onFCP.ts b/src/onFCP.ts index c9ed1f40..60cfce66 100644 --- a/src/onFCP.ts +++ b/src/onFCP.ts @@ -73,7 +73,7 @@ export const onFCP = (onReport: FCPReportCallback, opts?: ReportOpts) => { onReport, metric, FCPThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); // Only report after a bfcache restore if the `PerformanceObserver` @@ -84,7 +84,7 @@ export const onFCP = (onReport: FCPReportCallback, opts?: ReportOpts) => { onReport, metric, FCPThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); doubleRAF(() => { diff --git a/src/onFID.ts b/src/onFID.ts index f532edd1..c9ee655e 100644 --- a/src/onFID.ts +++ b/src/onFID.ts @@ -73,7 +73,7 @@ export const onFID = (onReport: FIDReportCallback, opts?: ReportOpts) => { onReport, metric, FIDThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); if (po) { @@ -81,19 +81,19 @@ export const onFID = (onReport: FIDReportCallback, opts?: ReportOpts) => { runOnce(() => { handleEntries(po.takeRecords() as FIDMetric['entries']); po.disconnect(); - }) + }), ); } if (window.__WEB_VITALS_POLYFILL__) { console.warn( - 'The web-vitals "base+polyfill" build is deprecated. See: https://bit.ly/3aqzsGm' + 'The web-vitals "base+polyfill" build is deprecated. See: https://bit.ly/3aqzsGm', ); // Prefer the native implementation if available, if (!po) { window.webVitals.firstInputPolyfill( - handleEntry as FirstInputPolyfillCallback + handleEntry as FirstInputPolyfillCallback, ); } onBFCacheRestore(() => { @@ -102,12 +102,12 @@ export const onFID = (onReport: FIDReportCallback, opts?: ReportOpts) => { onReport, metric, FIDThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); window.webVitals.resetFirstInputPolyfill(); window.webVitals.firstInputPolyfill( - handleEntry as FirstInputPolyfillCallback + handleEntry as FirstInputPolyfillCallback, ); }); } else { @@ -119,7 +119,7 @@ export const onFID = (onReport: FIDReportCallback, opts?: ReportOpts) => { onReport, metric, FIDThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); resetFirstInputPolyfill(); diff --git a/src/onINP.ts b/src/onINP.ts index ac23c2fe..73a46503 100644 --- a/src/onINP.ts +++ b/src/onINP.ts @@ -89,7 +89,7 @@ const processEntry = (entry: PerformanceEventTiming) => { existingInteraction.entries.push(entry); existingInteraction.latency = Math.max( existingInteraction.latency, - entry.duration + entry.duration, ); } else { const interaction = { @@ -116,7 +116,7 @@ const processEntry = (entry: PerformanceEventTiming) => { const estimateP98LongestInteraction = () => { const candidateInteractionIndex = Math.min( longestInteractionList.length - 1, - Math.floor(getInteractionCountForNavigation() / 50) + Math.floor(getInteractionCountForNavigation() / 50), ); return longestInteractionList[candidateInteractionIndex]; @@ -182,7 +182,7 @@ export const onINP = (onReport: INPReportCallback, opts?: ReportOpts) => { entry.startTime === prevEntry.startTime ); }); - } + }, ); if (noMatchingEntry) { processEntry(entry); @@ -213,7 +213,7 @@ export const onINP = (onReport: INPReportCallback, opts?: ReportOpts) => { onReport, metric, INPThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); if (po) { @@ -253,7 +253,7 @@ export const onINP = (onReport: INPReportCallback, opts?: ReportOpts) => { onReport, metric, INPThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); }); } diff --git a/src/onLCP.ts b/src/onLCP.ts index 161188bb..6e6da1c0 100644 --- a/src/onLCP.ts +++ b/src/onLCP.ts @@ -69,7 +69,7 @@ export const onLCP = (onReport: LCPReportCallback, opts?: ReportOpts) => { // clamped at 0. metric.value = Math.max( lastEntry.startTime - getActivationStart(), - 0 + 0, ); metric.entries = [lastEntry]; report(); @@ -84,7 +84,7 @@ export const onLCP = (onReport: LCPReportCallback, opts?: ReportOpts) => { onReport, metric, LCPThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); const stopListening = runOnce(() => { @@ -116,7 +116,7 @@ export const onLCP = (onReport: LCPReportCallback, opts?: ReportOpts) => { onReport, metric, LCPThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); doubleRAF(() => { diff --git a/src/onTTFB.ts b/src/onTTFB.ts index 1ecf865b..cd3d3aeb 100644 --- a/src/onTTFB.ts +++ b/src/onTTFB.ts @@ -68,7 +68,7 @@ export const onTTFB = (onReport: TTFBReportCallback, opts?: ReportOpts) => { onReport, metric, TTFBThresholds, - opts.reportAllChanges + opts.reportAllChanges, ); whenReady(() => { @@ -102,7 +102,7 @@ export const onTTFB = (onReport: TTFBReportCallback, opts?: ReportOpts) => { onReport, metric, TTFBThresholds, - opts!.reportAllChanges + opts!.reportAllChanges, ); report(true); diff --git a/test/e2e/onCLS-test.js b/test/e2e/onCLS-test.js index fc1d74ed..8a0dd903 100644 --- a/test/e2e/onCLS-test.js +++ b/test/e2e/onCLS-test.js @@ -743,7 +743,7 @@ describe('onCLS()', async function () { assert.match(cls.navigationType, /navigate|reload/); const {largestShiftEntry, largestShiftSource} = getAttribution( - cls.entries + cls.entries, ); assert.deepEqual(cls.attribution.largestShiftEntry, largestShiftEntry); @@ -753,13 +753,13 @@ describe('onCLS()', async function () { assert.equal(cls.attribution.largestShiftTarget, '#p3'); assert.equal( cls.attribution.largestShiftTime, - largestShiftEntry.startTime + largestShiftEntry.startTime, ); // The first shift (before the second image loads) is the largest. assert.match( cls.attribution.loadState, - /^dom-(interactive|content-loaded)$/ + /^dom-(interactive|content-loaded)$/, ); }); @@ -784,7 +784,7 @@ describe('onCLS()', async function () { assert.match(cls.navigationType, /navigate|reload/); const {largestShiftEntry, largestShiftSource} = getAttribution( - cls.entries + cls.entries, ); assert.deepEqual(cls.attribution.largestShiftEntry, largestShiftEntry); @@ -794,7 +794,7 @@ describe('onCLS()', async function () { assert.equal(cls.attribution.largestShiftTarget, 'html>body>main>h1'); assert.equal( cls.attribution.largestShiftTime, - largestShiftEntry.startTime + largestShiftEntry.startTime, ); // The first shift (before the second image loads) is the largest. diff --git a/test/e2e/onFCP-test.js b/test/e2e/onFCP-test.js index be3c5479..1e7454d4 100644 --- a/test/e2e/onFCP-test.js +++ b/test/e2e/onFCP-test.js @@ -299,11 +299,11 @@ describe('onFCP()', async function () { assert.equal(fcp.attribution.timeToFirstByte, navEntry.responseStart); assert.equal( fcp.attribution.firstByteToFCP, - fcp.value - navEntry.responseStart + fcp.value - navEntry.responseStart, ); assert.match( fcp.attribution.loadState, - /^(loading|dom-(interactive|content-loaded)|complete)$/ + /^(loading|dom-(interactive|content-loaded)|complete)$/, ); assert.deepEqual(fcp.attribution.fcpEntry, fcpEntry); @@ -350,11 +350,11 @@ describe('onFCP()', async function () { assert.equal( fcp.attribution.timeToFirstByte, - Math.max(0, navEntry.responseStart - activationStart) + Math.max(0, navEntry.responseStart - activationStart), ); assert.equal( fcp.attribution.firstByteToFCP, - fcp.value - Math.max(0, navEntry.responseStart - activationStart) + fcp.value - Math.max(0, navEntry.responseStart - activationStart), ); assert.deepEqual(fcp.attribution.fcpEntry, fcpEntry); diff --git a/test/e2e/onINP-test.js b/test/e2e/onINP-test.js index f14da064..b419a34f 100644 --- a/test/e2e/onINP-test.js +++ b/test/e2e/onINP-test.js @@ -110,7 +110,7 @@ describe('onINP()', async function () { if (!browserSupportsINP) this.skip(); await browser.url( - '/test/inp?click=100&reportAllChanges=1&loadAfterInput=1' + '/test/inp?click=100&reportAllChanges=1&loadAfterInput=1', ); const h1 = await $('h1'); @@ -495,7 +495,7 @@ describe('onINP()', async function () { await browser.url( '/test/inp?' + - 'attribution=1&reportAllChanges=1&click=100&delayDCL=1000' + 'attribution=1&reportAllChanges=1&click=100&delayDCL=1000', ); // Click on the

. @@ -512,7 +512,7 @@ describe('onINP()', async function () { await browser.url( '/test/inp?' + - 'attribution=1&reportAllChanges=1&click=100&delayResponse=1000' + 'attribution=1&reportAllChanges=1&click=100&delayResponse=1000', ); // Click on the