refactor: code cleanup after eslint 9 migration
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 30 May 2024 19:58:41 +0000 (21:58 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 30 May 2024 19:58:41 +0000 (21:58 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/abstract-pool.ts
src/pools/selection-strategies/selection-strategies-utils.ts
src/pools/selection-strategies/worker-choice-strategies-context.ts
tests/utils.test.mjs

index c8a87251df2f5701e92c16603870fa17a30a5d38..e4dac676ab95acae7ee60a82d332084766735e46 100644 (file)
@@ -1185,7 +1185,6 @@ export abstract class AbstractPool<
       const workerNodeKey = this.chooseWorkerNode(name)
       const task: Task<Data> = {
         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<Response>
   ): 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<Response>
index 07517535e57ba7f7fc645973c3bfe406f9900271..007f1e574bc4cf1b505f5b1f3d728db990fad6cb 100644 (file)
@@ -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()
   }
index d030a4524351beea255a1d57edda357435b70013..b7b0ad5633ca53bbbf459f18ea189996a08091cf 100644 (file)
@@ -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.
    */
index b977e102330e52440c618fdadf65b8bef0f51972..25b4e5ae0cfd21cc84e5fb523748e84e44a95e0b 100644 (file)
@@ -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)