From ec8ed549f5422b9c23ff5b446ec885f39656373d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 30 May 2024 21:58:41 +0200 Subject: [PATCH] refactor: code cleanup after eslint 9 migration MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/abstract-pool.ts | 10 ++-------- .../selection-strategies/selection-strategies-utils.ts | 1 - .../worker-choice-strategies-context.ts | 4 ++-- tests/utils.test.mjs | 1 - 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index c8a87251..e4dac676 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1185,7 +1185,6 @@ export abstract class AbstractPool< const workerNodeKey = this.chooseWorkerNode(name) const task: Task = { name: name ?? DEFAULT_TASK_NAME, - data: data ?? ({} as Data), priority: this.getWorkerNodeTaskFunctionPriority(workerNodeKey, name), strategy: this.getWorkerNodeTaskFunctionWorkerChoiceStrategy( @@ -1222,7 +1221,7 @@ export abstract class AbstractPool< /** * Starts the minimum number of workers. - * @param initWorkerNodeUsage + * @param initWorkerNodeUsage - Whether to initialize the worker node usage or not. @defaultValue false */ private startMinimumNumberOfWorkers (initWorkerNodeUsage = false): void { this.startingMinimumNumberOfWorkers = true @@ -1392,7 +1391,6 @@ export abstract class AbstractPool< message: MessageValue ): void { let needWorkerChoiceStrategiesUpdate = false - if (this.workerNodes[workerNodeKey]?.usage != null) { const workerUsage = this.workerNodes[workerNodeKey].usage updateTaskStatisticsWorkerUsage(workerUsage, message) @@ -1570,7 +1568,6 @@ export abstract class AbstractPool< ) { this.redistributeQueuedTasks(this.workerNodes.indexOf(workerNode)) } - workerNode?.terminate().catch((error: unknown) => { this.emitter?.emit(PoolEvents.error, error) }) @@ -1789,7 +1786,6 @@ export abstract class AbstractPool< taskName: string ): void { const workerNode = this.workerNodes[workerNodeKey] - if (workerNode?.usage != null) { ++workerNode.usage.tasks.stolen } @@ -1808,7 +1804,6 @@ export abstract class AbstractPool< previousTaskName?: string ): void { const workerNode = this.workerNodes[workerNodeKey] - if (workerNode?.usage != null) { ++workerNode.usage.tasks.sequentiallyStolen } @@ -1837,7 +1832,6 @@ export abstract class AbstractPool< taskName: string ): void { const workerNode = this.workerNodes[workerNodeKey] - if (workerNode?.usage != null) { workerNode.usage.tasks.sequentiallyStolen = 0 } @@ -2003,7 +1997,7 @@ export abstract class AbstractPool< /** * This method is the message listener registered on each worker. - * @param message + * @param message - The message received from the worker. */ protected readonly workerMessageListener = ( message: MessageValue diff --git a/src/pools/selection-strategies/selection-strategies-utils.ts b/src/pools/selection-strategies/selection-strategies-utils.ts index 07517535..007f1e57 100644 --- a/src/pools/selection-strategies/selection-strategies-utils.ts +++ b/src/pools/selection-strategies/selection-strategies-utils.ts @@ -33,7 +33,6 @@ const estimatedCpuSpeed = (): number => { const getDefaultWorkerWeight = (): number => { const currentCpus = cpus() let estCpuSpeed: number | undefined - if (currentCpus.every(cpu => cpu.speed == null || cpu.speed === 0)) { estCpuSpeed = estimatedCpuSpeed() } diff --git a/src/pools/selection-strategies/worker-choice-strategies-context.ts b/src/pools/selection-strategies/worker-choice-strategies-context.ts index d030a452..b7b0ad56 100644 --- a/src/pools/selection-strategies/worker-choice-strategies-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategies-context.ts @@ -128,7 +128,7 @@ export class WorkerChoiceStrategiesContext< /** * Updates the worker node key in the active worker choice strategies in the context internals. - * @param workerNodeKey + * @param workerNodeKey - The worker node key. * @returns `true` if the update is successful, `false` otherwise. */ public update (workerNodeKey: number): boolean { @@ -233,7 +233,7 @@ export class WorkerChoiceStrategiesContext< /** * Adds a worker choice strategy to the context. * @param workerChoiceStrategy - The worker choice strategy to add. - * @param pool + * @param pool - The pool instance. * @param opts - The worker choice strategy options. * @returns The worker choice strategies. */ diff --git a/tests/utils.test.mjs b/tests/utils.test.mjs index b977e102..25b4e5ae 100644 --- a/tests/utils.test.mjs +++ b/tests/utils.test.mjs @@ -150,7 +150,6 @@ describe('Utils test suite', () => { expect(isAsyncFunction('')).toBe(false) expect(isAsyncFunction([])).toBe(false) expect(isAsyncFunction(new Date())).toBe(false) - expect(isAsyncFunction(/[a-z]/i)).toBe(false) expect(isAsyncFunction(new Error())).toBe(false) expect(isAsyncFunction(new Map())).toBe(false) -- 2.34.1