From: Jérôme Benoit Date: Mon, 1 May 2023 12:41:45 +0000 (+0200) Subject: refactor: use eslint plugin to sort imports X-Git-Tag: v2.4.12~32 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=65d7a1c9177d558c01570f4013b7aa23bbee952d;p=poolifier.git refactor: use eslint plugin to sort imports Signed-off-by: Jérôme Benoit --- diff --git a/.eslintrc.js b/.eslintrc.js index c4f0c6d2..6ff6e4c1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,12 +19,12 @@ module.exports = defineConfig({ ], rules: { 'sort-imports': [ - 'warn', + 'error', { - ignoreMemberSort: true, ignoreDeclarationSort: true } ], + 'import/order': 'error', 'spellcheck/spell-checker': [ 'warn', diff --git a/benchmarks/benchmarks-utils.js b/benchmarks/benchmarks-utils.js index aac4b785..743936da 100644 --- a/benchmarks/benchmarks-utils.js +++ b/benchmarks/benchmarks-utils.js @@ -1,16 +1,16 @@ const crypto = require('crypto') const fs = require('fs') -const { - PoolTypes, - WorkerFunctions, - WorkerTypes -} = require('./benchmarks-types') const { DynamicClusterPool, DynamicThreadPool, FixedClusterPool, FixedThreadPool } = require('../lib') +const { + PoolTypes, + WorkerFunctions, + WorkerTypes +} = require('./benchmarks-types') async function runTest (pool, { taskExecutions, workerData }) { return new Promise((resolve, reject) => { diff --git a/examples/yourWorker.js b/examples/yourWorker.js index 5bd1ad65..7de9485c 100644 --- a/examples/yourWorker.js +++ b/examples/yourWorker.js @@ -1,6 +1,6 @@ 'use strict' -const { ThreadWorker } = require('poolifier') const { isMainThread } = require('worker_threads') +const { ThreadWorker } = require('poolifier') const debug = false diff --git a/package.json b/package.json index 0ec8aa6f..ea732c9a 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,6 @@ "mocha": "^10.2.0", "mochawesome": "^7.1.3", "prettier": "^2.8.8", - "prettier-plugin-organize-imports": "^3.2.2", "release-it": "^15.10.2", "rollup": "^3.21.2", "rollup-plugin-analyzer": "^4.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f005e64..ff49f4dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -88,9 +88,6 @@ devDependencies: prettier: specifier: ^2.8.8 version: 2.8.8 - prettier-plugin-organize-imports: - specifier: ^3.2.2 - version: 3.2.2(prettier@2.8.8)(typescript@5.0.4) release-it: specifier: ^15.10.2 version: 15.10.2 @@ -4758,23 +4755,6 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier-plugin-organize-imports@3.2.2(prettier@2.8.8)(typescript@5.0.4): - resolution: {integrity: sha512-e97lE6odGSiHonHJMTYC0q0iLXQyw0u5z/PJpvP/3vRy6/Zi9kLBwFAbEGjDzIowpjQv8b+J04PDamoUSQbzGA==} - peerDependencies: - '@volar/vue-language-plugin-pug': ^1.0.4 - '@volar/vue-typescript': ^1.0.4 - prettier: '>=2.0' - typescript: '>=2.9' - peerDependenciesMeta: - '@volar/vue-language-plugin-pug': - optional: true - '@volar/vue-typescript': - optional: true - dependencies: - prettier: 2.8.8 - typescript: 5.0.4 - dev: true - /prettier@2.8.8: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index e0feb5ed..2ee3a0cc 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -6,13 +6,14 @@ import { median } from '../utils' import { KillBehaviors, isKillBehavior } from '../worker/worker-options' +import { CircularArray } from '../circular-array' import { + type IPool, PoolEmitter, PoolEvents, - type IPool, type PoolOptions, - type TasksQueueOptions, - PoolType + PoolType, + type TasksQueueOptions } from './pool' import type { IWorker, Task, TasksUsage, WorkerNode } from './worker' import { @@ -21,7 +22,6 @@ import { type WorkerChoiceStrategyOptions } from './selection-strategies/selection-strategies-types' import { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context' -import { CircularArray } from '../circular-array' /** * Base class that implements some shared logic for all poolifier pools. diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index e29c1e38..3dda355e 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -1,5 +1,5 @@ import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils' -import { PoolType, type IPool } from '../pool' +import { type IPool, PoolType } from '../pool' import type { IWorker } from '../worker' import type { IWorkerChoiceStrategy, diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index c5c20437..53b2d64d 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -1,13 +1,13 @@ import { cpus } from 'node:os' import type { IWorker } from '../worker' +import type { IPool } from '../pool' +import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils' import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy' import type { IWorkerChoiceStrategy, RequiredStatistics, WorkerChoiceStrategyOptions } from './selection-strategies-types' -import type { IPool } from '../pool' -import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils' /** * Virtual task runtime. diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index 7753d1d6..570c9c8b 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -1,8 +1,8 @@ import { - isMainThread, MessageChannel, SHARE_ENV, - Worker + Worker, + isMainThread } from 'node:worker_threads' import type { Draft, MessageValue } from '../../utility-types' import { AbstractPool } from '../abstract-pool' diff --git a/tests/worker-files/cluster/testWorker.js b/tests/worker-files/cluster/testWorker.js index ee82c654..3f50d102 100644 --- a/tests/worker-files/cluster/testWorker.js +++ b/tests/worker-files/cluster/testWorker.js @@ -1,6 +1,6 @@ 'use strict' -const { ClusterWorker, KillBehaviors } = require('../../../lib') const { isMaster } = require('cluster') +const { ClusterWorker, KillBehaviors } = require('../../../lib') const TestUtils = require('../../test-utils') const { WorkerFunctions } = require('../../test-types') diff --git a/tests/worker-files/thread/testWorker.js b/tests/worker-files/thread/testWorker.js index 2b86fde2..177ef08b 100644 --- a/tests/worker-files/thread/testWorker.js +++ b/tests/worker-files/thread/testWorker.js @@ -1,6 +1,6 @@ 'use strict' -const { ThreadWorker, KillBehaviors } = require('../../../lib') const { isMainThread } = require('worker_threads') +const { ThreadWorker, KillBehaviors } = require('../../../lib') const TestUtils = require('../../test-utils') const { WorkerFunctions } = require('../../test-types')