Skip to content

Commit 709ce20

Browse files
authored
Merge pull request #45 from MatrixAI/feature-fix-linting-errors
Fix leftover linting errors
2 parents 768e09d + 8cafbe7 commit 709ce20

8 files changed

+16
-14
lines changed

src/CreateDestroy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Status, Class } from './types.js';
1+
import type { Status, Class, AnyFn } from './types.js';
22
import { Evented } from '@matrixai/events';
33
import { RWLockWriter } from '@matrixai/async-locks';
44
import {
@@ -118,7 +118,7 @@ function ready(
118118
} else if (descriptor.set != null) {
119119
kind = 'set';
120120
}
121-
const f: Function = descriptor[kind]; // eslint-disable-line @typescript-eslint/ban-types
121+
const f = descriptor[kind] as AnyFn;
122122
if (typeof f !== 'function') {
123123
throw new TypeError(`${key} is not a function`);
124124
}

src/CreateDestroyStartStop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Status, Class } from './types.js';
1+
import type { Status, Class, AnyFn } from './types.js';
22
import { Evented } from '@matrixai/events';
33
import { RWLockWriter } from '@matrixai/async-locks';
44
import {
@@ -238,7 +238,7 @@ function ready(
238238
} else if (descriptor.set != null) {
239239
kind = 'set';
240240
}
241-
const f: Function = descriptor[kind]; // eslint-disable-line @typescript-eslint/ban-types
241+
const f = descriptor[kind] as AnyFn;
242242
if (typeof f !== 'function') {
243243
throw new TypeError(`${key} is not a function`);
244244
}

src/StartStop.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ function ready(
159159
} else if (descriptor.set != null) {
160160
kind = 'set';
161161
}
162-
const f: Function = descriptor[kind]; // eslint-disable-line @typescript-eslint/ban-types
162+
type AnyFn = (...args: Array<unknown>) => unknown;
163+
const f = descriptor[kind] as AnyFn;
163164
if (typeof f !== 'function') {
164165
throw new TypeError(`${key} is not a function`);
165166
}

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ type Status = 'destroying' | 'starting' | 'stopping' | null;
1111

1212
type Class<T> = new (...args: any[]) => T;
1313

14-
export type { PromiseDeconstructed, Status, Class };
14+
type AnyFn = (...args: Array<unknown>) => unknown;
15+
16+
export type { PromiseDeconstructed, Status, Class, AnyFn };

src/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { PromiseDeconstructed } from './types.js';
1+
import type { AnyFn, PromiseDeconstructed } from './types.js';
22

33
/**
44
* Symbols prevents name clashes with decorated classes
@@ -42,8 +42,7 @@ function promise<T = void>(): PromiseDeconstructed<T> {
4242
* This function rewrites the stack trace according to where the wrapped
4343
* function is called, giving a more useful stack trace
4444
*/
45-
// eslint-disable-next-line @typescript-eslint/ban-types
46-
function resetStackTrace(error: Error, decorated?: Function): void {
45+
function resetStackTrace(error: Error, decorated?: AnyFn): void {
4746
if (error.stack != null) {
4847
const stackTitle = error.stack.slice(0, error.stack.indexOf('\n') + 1);
4948
if (hasCaptureStackTrace) {

tests/CreateDestroy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ describe('CreateDestroy', () => {
377377
(async () => {
378378
const x = new X();
379379
const destroy = x.destroy();
380-
x.a;
380+
void x.a;
381381
await destroy;
382382
})(),
383383
).resolves.toBeUndefined();

tests/CreateDestroyStartStop.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ describe('CreateDestroyStartStop', () => {
596596
await expect(
597597
(async () => {
598598
const start = x.start();
599-
x.a;
599+
void x.a;
600600
await start;
601601
})(),
602602
).rejects.toThrow(ErrorAsyncInitNotRunning);
@@ -614,7 +614,7 @@ describe('CreateDestroyStartStop', () => {
614614
await expect(
615615
(async () => {
616616
const stop = x.stop();
617-
x.a;
617+
void x.a;
618618
await stop;
619619
})(),
620620
).resolves.toBeUndefined();

tests/StartStop.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ describe('StartStop', () => {
311311
await expect(
312312
(async () => {
313313
const start = x.start();
314-
x.a;
314+
void x.a;
315315
await start;
316316
})(),
317317
).rejects.toThrow(ErrorAsyncInitNotRunning);
@@ -329,7 +329,7 @@ describe('StartStop', () => {
329329
await expect(
330330
(async () => {
331331
const stop = x.stop();
332-
x.a;
332+
void x.a;
333333
await stop;
334334
})(),
335335
).resolves.toBeUndefined();

0 commit comments

Comments
 (0)