Skip to content

Commit

Permalink
Fix formating issues after eslint update
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton committed Dec 27, 2023
1 parent 4f08663 commit 73c9f0d
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 105 deletions.
22 changes: 2 additions & 20 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/attribution/onCLS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
};
4 changes: 2 additions & 2 deletions src/attribution/onFCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
};
4 changes: 2 additions & 2 deletions src/attribution/onFID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
};
4 changes: 2 additions & 2 deletions src/attribution/onINP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
};
10 changes: 5 additions & 5 deletions src/attribution/onLCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
);
};
10 changes: 5 additions & 5 deletions src/attribution/onTTFB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
);
};
2 changes: 1 addition & 1 deletion src/lib/bfcache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export const onBFCacheRestore = (cb: onBFCacheRestoreCallback) => {
cb(event);
}
},
true
true,
);
};
4 changes: 2 additions & 2 deletions src/lib/bindReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -33,7 +33,7 @@ export const bindReporter = <MetricName extends MetricType['name']>(
callback: (metric: Extract<MetricType, {name: MetricName}>) => void,
metric: Extract<MetricType, {name: MetricName}>,
thresholds: MetricRatingThresholds,
reportAllChanges?: boolean
reportAllChanges?: boolean,
) => {
let prevValue: number;
let delta: number;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/getNavigationEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getNavigationEntryFromPerformanceTiming =
navigationEntry[key] = Math.max(
(timing[key as keyof PerformanceTiming] as number) -
timing.navigationStart,
0
0,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/initMetric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {MetricType} from '../types.js';

export const initMetric = <MetricName extends MetricType['name']>(
name: MetricName,
value?: number
value?: number,
) => {
const navEntry = getNavigationEntry();
let navigationType: MetricType['navigationType'] = 'navigate';
Expand All @@ -37,7 +37,7 @@ export const initMetric = <MetricName extends MetricType['name']>(
} else if (navEntry.type) {
navigationType = navEntry.type.replace(
/_/g,
'-'
'-',
) as MetricType['navigationType'];
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface PerformanceEntryMap {
export const observe = <K extends keyof PerformanceEntryMap>(
type: K,
callback: (entries: PerformanceEntryMap[K]) => void,
opts?: PerformanceObserverInit
opts?: PerformanceObserverInit,
): PerformanceObserver | undefined => {
try {
if (PerformanceObserver.supportedEntryTypes.includes(type)) {
Expand All @@ -58,8 +58,8 @@ export const observe = <K extends keyof PerformanceEntryMap>(
type,
buffered: true,
},
opts || {}
) as PerformanceObserverInit
opts || {},
) as PerformanceObserverInit,
);
return po;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/polyfills/firstInputPolyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const startTimeStamp: Date = new Date();
* are known.
*/
export const firstInputPolyfill = (
onFirstInput: FirstInputPolyfillCallback
onFirstInput: FirstInputPolyfillCallback,
) => {
callbacks.push(onFirstInput);
reportFirstInputDelayIfRecordedAndValid();
Expand Down
6 changes: 3 additions & 3 deletions src/onCLS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const onCLS = (onReport: CLSReportCallback, opts?: ReportOpts) => {
onReport,
metric,
CLSThresholds,
opts!.reportAllChanges
opts!.reportAllChanges,
);

onHidden(() => {
Expand All @@ -124,7 +124,7 @@ export const onCLS = (onReport: CLSReportCallback, opts?: ReportOpts) => {
onReport,
metric,
CLSThresholds,
opts!.reportAllChanges
opts!.reportAllChanges,
);

doubleRAF(() => report());
Expand All @@ -135,6 +135,6 @@ export const onCLS = (onReport: CLSReportCallback, opts?: ReportOpts) => {
// `reportAllChanges` is true.
setTimeout(report, 0);
}
})
}),
);
};
4 changes: 2 additions & 2 deletions src/onFCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -84,7 +84,7 @@ export const onFCP = (onReport: FCPReportCallback, opts?: ReportOpts) => {
onReport,
metric,
FCPThresholds,
opts!.reportAllChanges
opts!.reportAllChanges,
);

doubleRAF(() => {
Expand Down
14 changes: 7 additions & 7 deletions src/onFID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,27 @@ export const onFID = (onReport: FIDReportCallback, opts?: ReportOpts) => {
onReport,
metric,
FIDThresholds,
opts!.reportAllChanges
opts!.reportAllChanges,
);

if (po) {
onHidden(
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(() => {
Expand All @@ -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 {
Expand All @@ -119,7 +119,7 @@ export const onFID = (onReport: FIDReportCallback, opts?: ReportOpts) => {
onReport,
metric,
FIDThresholds,
opts!.reportAllChanges
opts!.reportAllChanges,
);

resetFirstInputPolyfill();
Expand Down
10 changes: 5 additions & 5 deletions src/onINP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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];
Expand Down Expand Up @@ -182,7 +182,7 @@ export const onINP = (onReport: INPReportCallback, opts?: ReportOpts) => {
entry.startTime === prevEntry.startTime
);
});
}
},
);
if (noMatchingEntry) {
processEntry(entry);
Expand Down Expand Up @@ -213,7 +213,7 @@ export const onINP = (onReport: INPReportCallback, opts?: ReportOpts) => {
onReport,
metric,
INPThresholds,
opts!.reportAllChanges
opts!.reportAllChanges,
);

if (po) {
Expand Down Expand Up @@ -253,7 +253,7 @@ export const onINP = (onReport: INPReportCallback, opts?: ReportOpts) => {
onReport,
metric,
INPThresholds,
opts!.reportAllChanges
opts!.reportAllChanges,
);
});
}
Expand Down
Loading

0 comments on commit 73c9f0d

Please sign in to comment.