Skip to content

Commit

Permalink
style: fix errors reported by eslint (when running on all files)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastian Krol committed Nov 14, 2023
1 parent 21ccfa0 commit 21e4a4f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test/e2e/05_fetch/graphql_apollo/**/*.js
test/experiments/errors/**/*.js
41 changes: 22 additions & 19 deletions lib/timings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -90,7 +94,6 @@ export function addTimingToPageLoadBeacon(beacon: PageLoadBeacon) {
addFirstPaintTimings(beacon, start);
}


function addFirstPaintTimings(beacon: PageLoadBeacon, start: number) {
if (!isResourceTimingAvailable) {
addFirstPaintFallbacks(beacon, start);
Expand All @@ -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;
}
}

Expand Down
1 change: 0 additions & 1 deletion secureWebVitalsLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/05_fetch/fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 21e4a4f

Please sign in to comment.