Skip to content

Commit

Permalink
chore: Fix lint warnings in instrumentation package (#2404)
Browse files Browse the repository at this point in the history
  • Loading branch information
alisabzevari committed Nov 10, 2021
1 parent e8e787d commit fdab642
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
Expand Up @@ -29,6 +29,7 @@ export function parseInstrumentationOptions(
): AutoLoaderResult {
let instrumentations: Instrumentation[] = [];
for (let i = 0, j = options.length; i < j; i++) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const option = options[i] as any;
if (Array.isArray(option)) {
const results = parseInstrumentationOptions(option);
Expand All @@ -53,7 +54,7 @@ export function enableInstrumentations(
instrumentations: Instrumentation[],
tracerProvider?: TracerProvider,
meterProvider?: MeterProvider
) {
): void {
for (let i = 0, j = instrumentations.length; i < j; i++) {
const instrumentation = instrumentations[i];
if (tracerProvider) {
Expand All @@ -76,6 +77,6 @@ export function enableInstrumentations(
* Disable instrumentations
* @param instrumentations
*/
export function disableInstrumentations(instrumentations: Instrumentation[]) {
export function disableInstrumentations(instrumentations: Instrumentation[]): void {
instrumentations.forEach(instrumentation => instrumentation.disable());
}
Expand Up @@ -74,31 +74,31 @@ export abstract class InstrumentationAbstract<T = any>
* Sets MeterProvider to this plugin
* @param meterProvider
*/
public setMeterProvider(meterProvider: MeterProvider) {
public setMeterProvider(meterProvider: MeterProvider): void {
this._meter = meterProvider.getMeter(
this.instrumentationName,
this.instrumentationVersion
);
}

/* Returns InstrumentationConfig */
public getConfig() {
public getConfig(): types.InstrumentationConfig {
return this._config;
}

/**
* Sets InstrumentationConfig to this plugin
* @param InstrumentationConfig
*/
public setConfig(config: types.InstrumentationConfig = {}) {
public setConfig(config: types.InstrumentationConfig = {}): void {
this._config = Object.assign({}, config);
}

/**
* Sets TraceProvider to this plugin
* @param tracerProvider
*/
public setTracerProvider(tracerProvider: TracerProvider) {
public setTracerProvider(tracerProvider: TracerProvider): void {
this._tracer = tracerProvider.getTracer(
this.instrumentationName,
this.instrumentationVersion
Expand Down
Expand Up @@ -102,7 +102,7 @@ export abstract class InstrumentationBase<T = any>
} else {
// internal file
const files = module.files ?? [];
const file = files.find(file => file.name === name);
const file = files.find(f => f.name === name);
if (file && isSupported(file.supportedVersions, version, module.includePrerelease)) {
file.moduleExports = exports;
if (this._enabled) {
Expand All @@ -113,7 +113,7 @@ export abstract class InstrumentationBase<T = any>
return exports;
}

public enable() {
public enable(): void {
if (this._enabled) {
return;
}
Expand Down Expand Up @@ -154,7 +154,7 @@ export abstract class InstrumentationBase<T = any>
}
}

public disable() {
public disable(): void {
if (!this._enabled) {
return;
}
Expand All @@ -172,7 +172,7 @@ export abstract class InstrumentationBase<T = any>
}
}

public isEnabled() {
public isEnabled(): boolean {
return this._enabled;
}
}
Expand Down
Expand Up @@ -45,6 +45,7 @@ export interface InstrumentationModuleDefinition<T> {
supportedVersions: string[];

/** Module internal files to be patched */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
files: InstrumentationModuleFile<any>[];

/** If set to true, the includePrerelease check will be included when calling semver.satisfies */
Expand Down
Expand Up @@ -77,8 +77,10 @@ export interface InstrumentationConfig {
* This interface defines the params that are be added to the wrapped function
* using the "shimmer.wrap"
*/
export interface ShimWrapped {
export interface ShimWrapped extends Function {
__wrapped: boolean;
// eslint-disable-next-line @typescript-eslint/ban-types
__unwrap: Function;
// eslint-disable-next-line @typescript-eslint/ban-types
__original: Function;
}
Expand Up @@ -73,7 +73,7 @@ export async function safeExecuteInTheMiddleAsync<T>(
* Checks if certain function has been already wrapped
* @param func
*/
export function isWrapped(func: any) {
export function isWrapped(func: unknown): func is ShimWrapped {
return (
typeof func === 'function' &&
typeof (func as ShimWrapped).__original === 'function' &&
Expand Down
Expand Up @@ -34,6 +34,7 @@ class FooInstrumentation extends InstrumentationBase {
}

describe('autoLoader', () => {
// eslint-disable-next-line @typescript-eslint/ban-types
let unload: Function | undefined;

afterEach(() => {
Expand Down

0 comments on commit fdab642

Please sign in to comment.