Skip to content

Commit

Permalink
chore(sdk-trace-web): fix lint warnings (#2451)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Dyla <[email protected]>
  • Loading branch information
alisabzevari and dyladan authored Nov 17, 2021
1 parent 58bfe25 commit a58f510
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
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 {
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

0 comments on commit a58f510

Please sign in to comment.