From 21e4a4f53601388eeed4c7377804c1ed9343ea44 Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Tue, 14 Nov 2023 12:21:24 +0100 Subject: [PATCH] style: fix errors reported by eslint (when running on all files) --- .eslintignore | 2 ++ lib/timings.js | 41 ++++++++++++++++++--------------- secureWebVitalsLoader.js | 1 - test/e2e/05_fetch/fetch.spec.js | 12 +++++----- 4 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..537b2106f --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +test/e2e/05_fetch/graphql_apollo/**/*.js +test/experiments/errors/**/*.js diff --git a/lib/timings.js b/lib/timings.js index e6254d4d0..d0ce03e8d 100644 --- a/lib/timings.js +++ b/lib/timings.js @@ -58,18 +58,22 @@ export function addTimingToPageLoadBeacon(beacon: PageLoadBeacon) { beacon['t_unl'] = timing.unloadEventEnd - timing.unloadEventStart; beacon['t_red'] = redirectTime; - beacon['t_apc'] = timing.domainLookupStart - (timing.fetchStart || timing.redirectEnd || timing.unloadEventEnd || timing.navigationStart); + beacon['t_apc'] = + timing.domainLookupStart - + (timing.fetchStart || timing.redirectEnd || timing.unloadEventEnd || timing.navigationStart); beacon['t_dns'] = timing.domainLookupEnd - timing.domainLookupStart; if (timing.connectStart > 0 && timing.connectEnd > 0) { - if (timing.secureConnectionStart != null - && timing.secureConnectionStart > 0 - // Issue in the navigation timing spec: Secure connection start does not take - // connection reuse into consideration. At the time of writing (2020-07-11) - // the latest W3C Navigation Timing recommendation still contains this issue. - // The latest editor draft has these fixed (by linking to the resource timing - // spec instead of duplicating the information). - // For now a workaround to avoid these wrong timings seems to be the following. - && timing.secureConnectionStart >= timing.connectStart) { + if ( + timing.secureConnectionStart != null && + timing.secureConnectionStart > 0 && + // Issue in the navigation timing spec: Secure connection start does not take + // connection reuse into consideration. At the time of writing (2020-07-11) + // the latest W3C Navigation Timing recommendation still contains this issue. + // The latest editor draft has these fixed (by linking to the resource timing + // spec instead of duplicating the information). + // For now a workaround to avoid these wrong timings seems to be the following. + timing.secureConnectionStart >= timing.connectStart + ) { beacon['t_tcp'] = timing.secureConnectionStart - timing.connectStart; beacon['t_ssl'] = timing.connectEnd - timing.secureConnectionStart; } else { @@ -90,7 +94,6 @@ export function addTimingToPageLoadBeacon(beacon: PageLoadBeacon) { addFirstPaintTimings(beacon, start); } - function addFirstPaintTimings(beacon: PageLoadBeacon, start: number) { if (!isResourceTimingAvailable) { addFirstPaintFallbacks(beacon, start); @@ -102,14 +105,14 @@ function addFirstPaintTimings(beacon: PageLoadBeacon, start: number) { for (let i = 0; i < paintTimings.length; i++) { const paintTiming = paintTimings[i]; switch (paintTiming.name) { - case 'first-paint': - beacon['t_fp'] = paintTiming.startTime | 0; - firstPaintFound = true; - break; - - case 'first-contentful-paint': - beacon['t_fcp'] = paintTiming.startTime | 0; - break; + case 'first-paint': + beacon['t_fp'] = paintTiming.startTime | 0; + firstPaintFound = true; + break; + + case 'first-contentful-paint': + beacon['t_fcp'] = paintTiming.startTime | 0; + break; } } diff --git a/secureWebVitalsLoader.js b/secureWebVitalsLoader.js index 7d0770c83..4d4d38e15 100644 --- a/secureWebVitalsLoader.js +++ b/secureWebVitalsLoader.js @@ -6,7 +6,6 @@ module.exports = () => ({ name: 'secureWebVitalsLoader', load(id) { if (id.endsWith('web-vitals/dist/web-vitals.js')) { - console.log('Adding try/catch to the web-vitals module'); const content = fs.readFileSync(id, {encoding: 'utf8'}); const parts = content.split('export{'); if (parts.length !== 2) { diff --git a/test/e2e/05_fetch/fetch.spec.js b/test/e2e/05_fetch/fetch.spec.js index 13639583f..817b120a0 100644 --- a/test/e2e/05_fetch/fetch.spec.js +++ b/test/e2e/05_fetch/fetch.spec.js @@ -570,8 +570,8 @@ describe('05_fetch', () => { it('must send form data in fetch requests', () => { return whenFetchIsSupported(() => retry(() => { - return Promise.all([getBeacons(), getAjaxRequests(), getResultElementContent(), getCapabilities()]) - .then(([beacons, ajaxRequests, result, capabilities]) => { + return Promise.all([getBeacons(), getAjaxRequests(), getResultElementContent()]) + .then(([beacons, ajaxRequests, result]) => { cexpect(beacons).to.have.lengthOf(2); cexpect(ajaxRequests).to.have.lengthOf(1); @@ -605,8 +605,8 @@ describe('05_fetch', () => { it('must send form data in fetch requests', () => { return whenFetchIsSupported(() => retry(() => { - return Promise.all([getBeacons(), getAjaxRequests(), getResultElementContent(), getCapabilities()]) - .then(([beacons, ajaxRequests, result, capabilities]) => { + return Promise.all([getBeacons(), getAjaxRequests(), getResultElementContent()]) + .then(([beacons, ajaxRequests, result]) => { cexpect(beacons).to.have.lengthOf(2); cexpect(ajaxRequests).to.have.lengthOf(1); @@ -639,8 +639,8 @@ describe('05_fetch', () => { it('must send csrf token in fetch requests', () => { return whenFetchIsSupported(() => retry(() => { - return Promise.all([getBeacons(), getAjaxRequests(), getResultElementContent(), getCapabilities()]) - .then(([beacons, ajaxRequests, result, capabilities]) => { + return Promise.all([getBeacons(), getAjaxRequests()]) + .then(([beacons, ajaxRequests]) => { cexpect(beacons).to.have.lengthOf(7); cexpect(ajaxRequests).to.have.lengthOf(6);