From 334d92430726c50a3f30e301b9d9587920945ea6 Mon Sep 17 00:00:00 2001 From: Ali Sabzevari Date: Fri, 3 Sep 2021 10:44:50 +0200 Subject: [PATCH 1/3] chore(sdk-trace-web): fix lint warnings --- .../src/StackContextManager.ts | 1 + .../src/WebTracerProvider.ts | 2 +- .../opentelemetry-sdk-trace-web/src/utils.ts | 18 +++++++++--------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-web/src/StackContextManager.ts b/packages/opentelemetry-sdk-trace-web/src/StackContextManager.ts index fb72c947ea..fa4e92ad1a 100644 --- a/packages/opentelemetry-sdk-trace-web/src/StackContextManager.ts +++ b/packages/opentelemetry-sdk-trace-web/src/StackContextManager.ts @@ -36,6 +36,7 @@ export class StackContextManager implements ContextManager { * @param context * @param target Function to be executed within the context */ + // eslint-disable-next-line @typescript-eslint/ban-types private _bindFunction( context = ROOT_CONTEXT, target: T diff --git a/packages/opentelemetry-sdk-trace-web/src/WebTracerProvider.ts b/packages/opentelemetry-sdk-trace-web/src/WebTracerProvider.ts index c97f4a4e6f..0317f48f86 100644 --- a/packages/opentelemetry-sdk-trace-web/src/WebTracerProvider.ts +++ b/packages/opentelemetry-sdk-trace-web/src/WebTracerProvider.ts @@ -55,7 +55,7 @@ export class WebTracerProvider extends BasicTracerProvider { * * @param config Configuration object for SDK registration */ - override register(config: SDKRegistrationConfig = {}) { + override register(config: SDKRegistrationConfig = {}): void { if (config.contextManager === undefined) { config.contextManager = new StackContextManager(); } diff --git a/packages/opentelemetry-sdk-trace-web/src/utils.ts b/packages/opentelemetry-sdk-trace-web/src/utils.ts index 9a16c64af8..5aa8e43bc1 100644 --- a/packages/opentelemetry-sdk-trace-web/src/utils.ts +++ b/packages/opentelemetry-sdk-trace-web/src/utils.ts @@ -108,10 +108,10 @@ export function addSpanNetworkEvents( * sort resources by startTime * @param filteredResources */ -export function sortResources(filteredResources: PerformanceResourceTiming[]) { - return filteredResources.slice().sort((a, b) => { - const valueA = a[PTN.FETCH_START]; - const valueB = b[PTN.FETCH_START]; +export function sortResources(filteredResources: PerformanceResourceTiming[]): PerformanceResourceTiming[] { + return filteredResources.slice().sort((x, y) => { + const valueA = x[PTN.FETCH_START]; + const valueB = y[PTN.FETCH_START]; if (valueA > valueB) { return 1; } else if (valueA < valueB) { @@ -284,9 +284,9 @@ function filterResourcesForSpan( * @param url */ export function parseUrl(url: string): HTMLAnchorElement { - const a = document.createElement('a'); - a.href = url; - return a; + const element = document.createElement('a'); + element.href = url; + return element; } /** @@ -296,7 +296,7 @@ export function parseUrl(url: string): HTMLAnchorElement { * simplified to contain id */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export function getElementXPath(target: any, optimised?: boolean) { +export function getElementXPath(target: any, optimised?: boolean): string { if (target.nodeType === Node.DOCUMENT_NODE) { return '/'; } @@ -380,7 +380,7 @@ function getNodeValue(target: HTMLElement, optimised?: boolean): string { export function shouldPropagateTraceHeaders( spanUrl: string, propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls -) { +): boolean { let propagateTraceHeaderUrls = propagateTraceHeaderCorsUrls || []; if ( typeof propagateTraceHeaderUrls === 'string' || From 40e0cdd7e359d808bbf170450f9f5d90333ff0ee Mon Sep 17 00:00:00 2001 From: Ali Sabzevari Date: Wed, 10 Nov 2021 19:26:41 +0100 Subject: [PATCH 2/3] chore(sdk-trace-web): rename the variable --- packages/opentelemetry-sdk-trace-web/src/utils.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-web/src/utils.ts b/packages/opentelemetry-sdk-trace-web/src/utils.ts index 5aa8e43bc1..23778eb4ea 100644 --- a/packages/opentelemetry-sdk-trace-web/src/utils.ts +++ b/packages/opentelemetry-sdk-trace-web/src/utils.ts @@ -29,13 +29,13 @@ import { import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; // Used to normalize relative URLs -let a: HTMLAnchorElement | undefined; +let urlNormalizingAnchor: HTMLAnchorElement | undefined; export function getUrlNormalizingAnchor(): HTMLAnchorElement { - if (!a) { - a = document.createElement('a'); + if (!urlNormalizingAnchor) { + urlNormalizingAnchor = document.createElement('a'); } - return a; + return urlNormalizingAnchor; } /** @@ -109,9 +109,9 @@ export function addSpanNetworkEvents( * @param filteredResources */ export function sortResources(filteredResources: PerformanceResourceTiming[]): PerformanceResourceTiming[] { - return filteredResources.slice().sort((x, y) => { - const valueA = x[PTN.FETCH_START]; - const valueB = y[PTN.FETCH_START]; + return filteredResources.slice().sort((a, b) => { + const valueA = a[PTN.FETCH_START]; + const valueB = b[PTN.FETCH_START]; if (valueA > valueB) { return 1; } else if (valueA < valueB) { From c48871b6544ae6899b490df09aa94b008b07632a Mon Sep 17 00:00:00 2001 From: Ali Sabzevari Date: Wed, 10 Nov 2021 19:57:15 +0100 Subject: [PATCH 3/3] chore(sdk-trace-web): fix lint warnings --- packages/opentelemetry-sdk-trace-web/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-sdk-trace-web/src/utils.ts b/packages/opentelemetry-sdk-trace-web/src/utils.ts index 23778eb4ea..829955feb0 100644 --- a/packages/opentelemetry-sdk-trace-web/src/utils.ts +++ b/packages/opentelemetry-sdk-trace-web/src/utils.ts @@ -295,7 +295,7 @@ export function parseUrl(url: string): HTMLAnchorElement { * @param optimised - when id attribute of element is present the xpath can be * simplified to contain id */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types export function getElementXPath(target: any, optimised?: boolean): string { if (target.nodeType === Node.DOCUMENT_NODE) { return '/';