Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sdk-trace-web): fix lint warnings #2451

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends Function>(
context = ROOT_CONTEXT,
target: T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
22 changes: 11 additions & 11 deletions packages/opentelemetry-sdk-trace-web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -108,7 +108,7 @@ export function addSpanNetworkEvents(
* sort resources by startTime
* @param filteredResources
*/
export function sortResources(filteredResources: PerformanceResourceTiming[]) {
export function sortResources(filteredResources: PerformanceResourceTiming[]): PerformanceResourceTiming[] {
return filteredResources.slice().sort((a, b) => {
const valueA = a[PTN.FETCH_START];
const valueB = b[PTN.FETCH_START];
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -295,8 +295,8 @@ 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
export function getElementXPath(target: any, optimised?: boolean) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
export function getElementXPath(target: any, optimised?: boolean): string {
dyladan marked this conversation as resolved.
Show resolved Hide resolved
if (target.nodeType === Node.DOCUMENT_NODE) {
return '/';
}
Expand Down Expand Up @@ -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' ||
Expand Down