Eslint configuration refinement (#97)
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 9 Feb 2021 16:43:36 +0000 (17:43 +0100)
committerGitHub <noreply@github.com>
Tue, 9 Feb 2021 16:43:36 +0000 (17:43 +0100)
.eslintrc.js
examples/typescript/pool.ts
package-lock.json
package.json
src/dynamic.ts
src/fixed.ts
src/index.ts
src/workers.ts

index a5c382c892f5547eddca28912a311ed4a445f690..8f902bd228e5b3a81ede40194c699f73ef121b66 100644 (file)
@@ -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'
+      }
     }
   ]
 }
index 50dcc7b779d7118b27f42c56136fca509d58a7f6..96b861c44bf2127f1d9d55c521cfb4e244590dc7 100644 (file)
@@ -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<MyData, Promise<MyResponse>>(
   8,
   join(__dirname, 'worker.js'),
index b49e20ddd3c37fed17f93717d89c029161b1f15d..e3e205ec54c92f77c03f5ae1a8a5989f8aee1000 100644 (file)
       "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",
index 693b3adc81c07a8253bd10d2f07ac043b71176c6..a30ae25f40d3ab173631481981481d49df39c75c 100644 (file)
@@ -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"
   },
     "@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"
   }
 }
index d8c189cfe2cab8fbb7d06d0aded7bfcc035720ae..b4c6bddf30e8e9c964cb1038a05a7788d6bce589 100644 (file)
@@ -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
index 80f4712640c8d6dbbc6761d7b7ac11c6e197b880..d2c6ba0c2fd542c8dd928d08ad6f54902224734b 100644 (file)
@@ -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<T> = { -readonly [P in keyof T]?: T[P] }
 
index 1d7e0b1fcfc5be98992f2cc5113a00b84ed6db12..4bd61868fe4b2365632b2e2a312be274f60752aa 100644 (file)
@@ -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 }
index e7db2c3fdeb5c1b1afa980b042c97c8cc0b703d0..57f2fd95bef547161ca510078a5191dd6bd0ee9b 100644 (file)
@@ -1,6 +1,5 @@
-import { isMainThread, parentPort } from 'worker_threads'
-
 import { AsyncResource } from 'async_hooks'
+import { isMainThread, parentPort } from 'worker_threads'
 
 export interface ThreadWorkerOptions {
   /**