Add eslint-plugin-jsdoc (#142)
authorShinigami <chrissi92@hotmail.de>
Sat, 13 Feb 2021 13:06:26 +0000 (14:06 +0100)
committerGitHub <noreply@github.com>
Sat, 13 Feb 2021 13:06:26 +0000 (14:06 +0100)
.eslintrc.js
package-lock.json
package.json
src/pools/abstract-pool.ts
src/pools/cluster/dynamic.ts
src/pools/thread/dynamic.ts
src/worker/abstract-worker.ts

index 04c5b05b596ab76bf7a9aa897900b190e4791b49..738e7df94c87ec612a42acc67b43dff4fbd6a048 100644 (file)
@@ -9,7 +9,7 @@ module.exports = {
     ecmaVersion: 2020,
     sourceType: 'module'
   },
-  plugins: ['@typescript-eslint', 'promise', 'prettierx'],
+  plugins: ['@typescript-eslint', 'promise', 'prettierx', 'jsdoc'],
   extends: [
     'standard',
     'eslint:recommended',
@@ -41,6 +41,15 @@ module.exports = {
     ]
   },
   overrides: [
+    {
+      files: ['src/**/*.ts'],
+      extends: 'plugin:jsdoc/recommended',
+      rules: {
+        'jsdoc/no-types': 'error',
+        'jsdoc/require-param-type': 'off',
+        'jsdoc/require-returns-type': 'off'
+      }
+    },
     {
       files: ['*.js'],
       extends: 'plugin:node/recommended',
index 30a6abd43713cdd7d5127cf7dcbe17cd1b890492..8d016514c033c9f091c8faa871fe9e4a48931a95 100644 (file)
       "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
       "dev": true
     },
+    "comment-parser": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.1.2.tgz",
+      "integrity": "sha512-AOdq0i8ghZudnYv8RUnHrhTgafUGs61Rdz9jemU5x2lnZwAWyOq7vySo626K59e1fVKH1xSRorJwPVRLSWOoAQ==",
+      "dev": true
+    },
     "commondir": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
       "dev": true
     },
     "electron-to-chromium": {
-      "version": "1.3.663",
-      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.663.tgz",
-      "integrity": "sha512-xkVkzHj6k3oRRGlmdgUCCLSLhtFYHDCTH7SeK+LJdJjnsLcrdbpr8EYmfMQhez3V/KPO5UScSpzQ0feYX6Qoyw==",
+      "version": "1.3.664",
+      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.664.tgz",
+      "integrity": "sha512-yb8LrTQXQnh9yhnaIHLk6CYugF/An50T20+X0h++hjjhVfgSp1DGoMSYycF8/aD5eiqS4QwaNhiduFvK8rifRg==",
       "dev": true
     },
     "emoji-regex": {
         }
       }
     },
+    "eslint-plugin-jsdoc": {
+      "version": "31.6.1",
+      "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-31.6.1.tgz",
+      "integrity": "sha512-5hCV3u+1VSEUMyfdTl+dpWsioD7tqQr2ILQw+KbXrF42AVxCLO8gnNLR6zDCDjqGGpt79V1sgY0RRchCWuCigg==",
+      "dev": true,
+      "requires": {
+        "comment-parser": "1.1.2",
+        "debug": "^4.3.1",
+        "jsdoctypeparser": "^9.0.0",
+        "lodash": "^4.17.20",
+        "regextras": "^0.7.1",
+        "semver": "^7.3.4",
+        "spdx-expression-parse": "^3.0.1"
+      }
+    },
     "eslint-plugin-node": {
       "version": "11.1.0",
       "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz",
       "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
       "dev": true
     },
+    "jsdoctypeparser": {
+      "version": "9.0.0",
+      "resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-9.0.0.tgz",
+      "integrity": "sha512-jrTA2jJIL6/DAEILBEh2/w9QxCuwmvNXIry39Ay/HVfhE3o2yVV0U44blYkqdHA/OKloJEqvJy0xU+GSdE2SIw==",
+      "dev": true
+    },
     "jsesc": {
       "version": "2.5.2",
       "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
         "unicode-match-property-value-ecmascript": "^1.2.0"
       }
     },
+    "regextras": {
+      "version": "0.7.1",
+      "resolved": "https://registry.npmjs.org/regextras/-/regextras-0.7.1.tgz",
+      "integrity": "sha512-9YXf6xtW+qzQ+hcMQXx95MOvfqXFgsKDZodX3qZB0x2n5Z94ioetIITsBtvJbiOyxa/6s9AtyweBLCdPmPko/w==",
+      "dev": true
+    },
     "regjsgen": {
       "version": "0.5.2",
       "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz",
index 0a905111233fefc8edb746f76a3a182640993b94..a69e76a7eb83a7a512be22f19b0f8df38c114eca 100644 (file)
@@ -63,6 +63,7 @@
     "eslint": "^7.20.0",
     "eslint-config-standard": "^16.0.2",
     "eslint-plugin-import": "^2.22.1",
+    "eslint-plugin-jsdoc": "^31.6.1",
     "eslint-plugin-node": "^11.1.0",
     "eslint-plugin-prettierx": "^0.17.1",
     "eslint-plugin-promise": "^4.3.1",
index 0763f04f9c21869e46b20414f4c998a03ad76bce..6b29669ff624a2ccdc58faebc2faa909125f97a0 100644 (file)
@@ -230,6 +230,8 @@ export abstract class AbstractPool<
    * Choose a worker for the next task.
    *
    * The default implementation uses a round robin algorithm to distribute the load.
+   *
+   * @returns Worker.
    */
   protected chooseWorker (): Worker {
     this.nextWorker =
@@ -253,6 +255,8 @@ export abstract class AbstractPool<
 
   /**
    * Creates a new worker for this pool and sets it up completely.
+   *
+   * @returns New, completely set up worker.
    */
   protected internalNewWorker (): Worker {
     const worker: Worker = this.newWorker()
index 99fa828d733e15f82363d373bb8fa593d383880f..3d523890463c1d82a05d200dd16a269557107220 100644 (file)
@@ -42,6 +42,8 @@ export class DynamicClusterPool<
    * It will first check for and return an idle worker.
    * If all workers are busy, then it will try to create a new one up to the `max` worker count.
    * If the max worker count is reached, the emitter will emit a `FullPool` event and it will fall back to using a round robin algorithm to distribute the load.
+   *
+   * @returns Cluster worker.
    */
   protected chooseWorker (): Worker {
     let worker: Worker | undefined
index 77f0a2d569618af2dbbd3d146078ae74be812165..c8e93850e537e0e1499b3c4ae72caa918704b6d5 100644 (file)
@@ -42,6 +42,8 @@ export class DynamicThreadPool<
    * It will first check for and return an idle thread.
    * If all threads are busy, then it will try to create a new one up to the `max` thread count.
    * If the max thread count is reached, the emitter will emit a `FullPool` event and it will fall back to using a round robin algorithm to distribute the load.
+   *
+   * @returns Thread worker.
    */
   protected chooseWorker (): ThreadWorkerWithMessageChannel {
     let worker: ThreadWorkerWithMessageChannel | undefined
index fd163547a78eb08c7ca0c0a93519374530ed5c8f..779088c56429780631385f78842dd6b8f01d336b 100644 (file)
@@ -86,6 +86,7 @@ export abstract class AbstractWorker<
    * Handle an error and convert it to a string so it can be sent back to the main worker.
    *
    * @param e The error raised by the worker.
+   * @returns Message of the error.
    */
   protected handleError (e: Error | string): string {
     return (e as unknown) as string