From b625d1cefe82191cbccc201b3556c5b871ffeb5a Mon Sep 17 00:00:00 2001 From: David Anson Date: Tue, 30 Jan 2024 19:40:41 -0800 Subject: [PATCH] Add JSDoc to linting via eslint-plugin-jsdoc, address newly-reported issues. --- .eslintrc.json | 2 ++ append-to-array.js | 6 +++--- merge-options.js | 6 +++--- package.json | 1 + parsers/jsonc-parse.js | 1 - parsers/yaml-parse.js | 1 - resolve-and-require.js | 8 ++++---- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9ab4a07..f8e9de7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,11 +8,13 @@ "es6": true }, "plugins": [ + "jsdoc", "n", "unicorn" ], "extends": [ "eslint:all", + "plugin:jsdoc/recommended", "plugin:n/recommended", "plugin:unicorn/all" ], diff --git a/append-to-array.js b/append-to-array.js index ed61664..4002d69 100644 --- a/append-to-array.js +++ b/append-to-array.js @@ -6,9 +6,9 @@ const sliceSize = 1000; /** * Efficiently appends the source array to the destination array. - * @param {Object[]} destination Destination Array. - * @param {Object[]} source Source Array. - * @returns void + * @param {object[]} destination Destination Array. + * @param {object[]} source Source Array. + * @returns {void} */ const appendToArray = (destination, source) => { // NOTE: destination.push(...source) throws "RangeError: Maximum call stack diff --git a/merge-options.js b/merge-options.js index e400989..915f5e4 100644 --- a/merge-options.js +++ b/merge-options.js @@ -4,9 +4,9 @@ /** * Merges two options objects by combining config and replacing properties. - * @param {Object} first First options object. - * @param {Object} second Second options object. - * @returns {Object} Merged options object. + * @param {object} first First options object. + * @param {object} second Second options object. + * @returns {object} Merged options object. */ const mergeOptions = (first, second) => { const merged = { diff --git a/package.json b/package.json index 791e501..8396f7d 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "cpy-cli": "5.0.0", "del": "7.1.0", "eslint": "8.56.0", + "eslint-plugin-jsdoc": "48.0.4", "eslint-plugin-n": "16.6.2", "eslint-plugin-unicorn": "50.0.1", "execa": "8.0.1", diff --git a/parsers/jsonc-parse.js b/parsers/jsonc-parse.js index 2ba94ac..3dd3030 100644 --- a/parsers/jsonc-parse.js +++ b/parsers/jsonc-parse.js @@ -6,7 +6,6 @@ const { parse, printParseErrorCode } = require("jsonc-parser"); /** * Parses a JSONC string, returning the corresponding object. - * * @param {string} text String to parse as JSONC. * @returns {object} Corresponding object. */ diff --git a/parsers/yaml-parse.js b/parsers/yaml-parse.js index 4b842d4..a036ca0 100644 --- a/parsers/yaml-parse.js +++ b/parsers/yaml-parse.js @@ -6,7 +6,6 @@ const yaml = require("yaml"); /** * Parses a YAML string, returning the corresponding object. - * * @param {string} text String to parse as YAML. * @returns {object} Corresponding object. */ diff --git a/resolve-and-require.js b/resolve-and-require.js index 3f16991..9507698 100644 --- a/resolve-and-require.js +++ b/resolve-and-require.js @@ -4,10 +4,10 @@ /** * Wrapper for calling Node's require.resolve/require with an additional path. - * @param {Object} req Node's require implementation (or equivalent). - * @param {String} id Package identifier to require. - * @param {String[]} dirs Directories to include when resolving paths. - * @returns {Object} Exported module content. + * @param {object} req Node's require implementation (or equivalent). + * @param {string} id Package identifier to require. + * @param {string[]} dirs Directories to include when resolving paths. + * @returns {object} Exported module content. */ const resolveAndRequire = (req, id, dirs) => { const resolvePaths = req.resolve.paths ? req.resolve.paths("") : [];