From fa699c4287a0a4940862e452109dddc7be53403b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 9 Feb 2021 17:43:36 +0100 Subject: [PATCH] Eslint configuration refinement (#97) --- .eslintrc.js | 25 +++++++++++++++++++++++-- examples/typescript/pool.ts | 3 +-- package-lock.json | 6 ++++++ package.json | 9 +++++---- src/dynamic.ts | 3 +-- src/fixed.ts | 2 +- src/index.ts | 2 +- src/workers.ts | 3 +-- 8 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a5c382c8..8f902bd2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,7 +6,7 @@ module.exports = { }, parser: '@typescript-eslint/parser', parserOptions: { - ecmaVersion: 12, + ecmaVersion: 2020, sourceType: 'module' }, plugins: ['@typescript-eslint', 'prettierx'], @@ -14,8 +14,14 @@ module.exports = { 'standard', 'eslint:recommended', 'plugin:@typescript-eslint/recommended', + 'plugin:import/errors', + 'plugin:import/warnings', + 'plugin:import/typescript', 'plugin:prettierx/standardx', - 'plugin:prettierx/@typescript-eslint' + 'plugin:prettierx/@typescript-eslint', + 'prettier', + 'prettier/standard', + 'prettier/@typescript-eslint' ], rules: { 'no-void': 'off', @@ -26,14 +32,29 @@ module.exports = { '@typescript-eslint/no-inferrable-types': [ 'error', { ignoreProperties: true } + ], + + 'sort-imports': [ + 'warn', + { + ignoreMemberSort: true, + memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'] + } ] }, overrides: [ { files: ['*.js'], rules: { + '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-var-requires': 'off' } + }, + { + files: ['examples/typescript/*.ts'], + rules: { + 'import/no-unresolved': 'off' + } } ] } diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index 50dcc7b7..96b861c4 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -1,8 +1,7 @@ +import { join } from 'path' import { DynamicThreadPool, FixedThreadPool } from 'poolifier' import { MyData, MyResponse } from './worker' -import { join } from 'path' - export const fixedPool = new FixedThreadPool>( 8, join(__dirname, 'worker.js'), diff --git a/package-lock.json b/package-lock.json index b49e20dd..e3e205ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3647,6 +3647,12 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", + "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", + "dev": true + }, "prettier-linter-helpers": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", diff --git a/package.json b/package.json index 693b3adc..a30ae25f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "test": "npm run build && nyc mocha --exit --timeout 20000 tests/*test.js ", "test:debug": "mocha --inspect-brk --exit tests/*test.js ", "coverage": "nyc report --reporter=text-lcov | coveralls", - "format": "prettierx --write .", + "format": "prettier --loglevel silent --write .; prettierx --write .", "lint": "eslint .", "lint:fix": "eslint . --fix" }, @@ -49,23 +49,24 @@ "@typescript-eslint/parser": "^4.15.0", "benchmark": "^2.1.4", "coveralls": "^3.1.0", + "eslint": "^7.19.0", "eslint-config-prettier": "^7.2.0", "eslint-config-standard": "^16.0.2", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettierx": "^0.17.0", "eslint-plugin-promise": "^4.2.1", - "eslint": "^7.19.0", "expect": "^26.6.2", - "mocha-lcov-reporter": "^1.3.0", "mocha": "^8.2.1", + "mocha-lcov-reporter": "^1.3.0", "nyc": "^15.1.0", + "prettier": "^2.2.1", "prettier-plugin-organize-imports": "^1.1.1", "prettierx": "^0.17.0", "rimraf": "^3.0.2", "typescript": "^4.1.3" }, "engines": { - "node": ">=12.0.0" + "node": ">=12.11.0" } } diff --git a/src/dynamic.ts b/src/dynamic.ts index d8c189cf..b4c6bddf 100644 --- a/src/dynamic.ts +++ b/src/dynamic.ts @@ -1,11 +1,10 @@ +import { EventEmitter } from 'events' import { FixedThreadPool, FixedThreadPoolOptions, WorkerWithMessageChannel } from './fixed' -import { EventEmitter } from 'events' - class MyEmitter extends EventEmitter {} export type DynamicThreadPoolOptions = FixedThreadPoolOptions diff --git a/src/fixed.ts b/src/fixed.ts index 80f47126..d2c6ba0c 100644 --- a/src/fixed.ts +++ b/src/fixed.ts @@ -1,4 +1,4 @@ -import { MessageChannel, SHARE_ENV, Worker, isMainThread } from 'worker_threads' +import { isMainThread, MessageChannel, SHARE_ENV, Worker } from 'worker_threads' export type Draft = { -readonly [P in keyof T]?: T[P] } diff --git a/src/index.ts b/src/index.ts index 1d7e0b1f..4bd61868 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,11 +2,11 @@ import { DynamicThreadPool } from './dynamic' import { FixedThreadPool } from './fixed' import { ThreadWorker } from './workers' +export { DynamicThreadPoolOptions } from './dynamic' export { Draft, FixedThreadPoolOptions, WorkerWithMessageChannel } from './fixed' -export { DynamicThreadPoolOptions } from './dynamic' export { ThreadWorkerOptions } from './workers' export { FixedThreadPool, DynamicThreadPool, ThreadWorker } diff --git a/src/workers.ts b/src/workers.ts index e7db2c3f..57f2fd95 100644 --- a/src/workers.ts +++ b/src/workers.ts @@ -1,6 +1,5 @@ -import { isMainThread, parentPort } from 'worker_threads' - import { AsyncResource } from 'async_hooks' +import { isMainThread, parentPort } from 'worker_threads' export interface ThreadWorkerOptions { /** -- 2.34.1