Skip to content

Commit

Permalink
refactor(sdk-trace-node): fix eslint warning
Browse files Browse the repository at this point in the history
```
/home/runner/work/opentelemetry-js/opentelemetry-js/packages/opentelemetry-sdk-trace-node/test/registration.test.ts
  30:61  warning  Don't use `Function` as a type  @typescript-eslint/ban-types
```

Here we are looking for a `AnyConstructor` type, and `Function` is
a close enough approximation that exists in the standard library.

The potential foot gun of _calling_ the function resulting in an
`any` value still exists, but this is a small function used in
tests only, so that's probably acceptable.

Ref open-telemetry#5365
  • Loading branch information
chancancode committed Jan 28, 2025
1 parent 199fd8d commit c01ffd8
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-ho
import { CompositePropagator } from '@opentelemetry/core';
import { NodeTracerProvider } from '../src';

const assertInstanceOf = (actual: object, ExpectedInstance: Function) => {
// Here we are looking for a `AnyConstructor` type, and `Function` is a close
// enough approximation that exists in the standard library.
// eslint-disable-next-line @typescript-eslint/ban-types
const assertInstanceOf = (actual: object, ExpectedConstructor: Function) => {
assert.ok(
actual instanceof ExpectedInstance,
`Expected ${inspect(actual)} to be instance of ${ExpectedInstance.name}`
actual instanceof ExpectedConstructor,
`Expected ${inspect(actual)} to be instance of ${ExpectedConstructor.name}`
);
};

Expand Down

0 comments on commit c01ffd8

Please # to comment.