From cf6379a5433cf1b0c959612d94c2c5c829280028 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 28 Nov 2021 22:48:00 -0800 Subject: [PATCH] lib,test,tools: use consistent JSDoc types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This could be in preparation of implementing the jsdoc/check-types ESLint rule. PR-URL: https://github.com/nodejs/node/pull/40989 Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel Reviewed-By: Tobias Nießen Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Ruben Bridgewater --- lib/fs.js | 12 ++++++------ lib/http.js | 4 ++-- lib/internal/errors.js | 2 +- lib/internal/modules/esm/loader.js | 10 +++++----- lib/internal/source_map/source_map.js | 2 +- lib/internal/util/inspect.js | 2 +- lib/v8.js | 2 +- test/async-hooks/hook-checks.js | 6 +++--- tools/eslint-rules/require-common-first.js | 6 +++--- tools/eslint-rules/required-modules.js | 6 +++--- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index 7e126b84adec76..86fb163f2a428c 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -784,7 +784,7 @@ function readvSync(fd, buffers, position) { /** * Writes `buffer` to the specified `fd` (file descriptor). * @param {number} fd - * @param {Buffer | TypedArray | DataView | string | Object} buffer + * @param {Buffer | TypedArray | DataView | string | object} buffer * @param {number} [offset] * @param {number} [length] * @param {number} [position] @@ -849,7 +849,7 @@ ObjectDefineProperty(write, internalUtil.customPromisifyArgs, * Synchronously writes `buffer` to the * specified `fd` (file descriptor). * @param {number} fd - * @param {Buffer | TypedArray | DataView | string | Object} buffer + * @param {Buffer | TypedArray | DataView | string | object} buffer * @param {number} [offset] * @param {number} [length] * @param {number} [position] @@ -2087,7 +2087,7 @@ function writeAll(fd, isUserFd, buffer, offset, length, signal, callback) { /** * Asynchronously writes data to the file. * @param {string | Buffer | URL | number} path - * @param {string | Buffer | TypedArray | DataView | Object} data + * @param {string | Buffer | TypedArray | DataView | object} data * @param {{ * encoding?: string | null; * mode?: number; @@ -2131,7 +2131,7 @@ function writeFile(path, data, options, callback) { /** * Synchronously writes data to the file. * @param {string | Buffer | URL | number} path - * @param {string | Buffer | TypedArray | DataView | Object} data + * @param {string | Buffer | TypedArray | DataView | object} data * @param {{ * encoding?: string | null; * mode?: number; @@ -2805,7 +2805,7 @@ function copyFileSync(src, dest, mode) { * symlink. The contents of directories will be copied recursively. * @param {string | URL} src * @param {string | URL} dest - * @param {Object} [options] + * @param {object} [options] * @param {() => any} callback * @returns {void} */ @@ -2827,7 +2827,7 @@ function cp(src, dest, options, callback) { * symlink. The contents of directories will be copied recursively. * @param {string | URL} src * @param {string | URL} dest - * @param {Object} [options] + * @param {object} [options] * @returns {void} */ function cpSync(src, dest, options) { diff --git a/lib/http.js b/lib/http.js index 38f1297be7921f..5120ec65e3f25b 100644 --- a/lib/http.js +++ b/lib/http.js @@ -60,13 +60,13 @@ function createServer(opts, requestListener) { } /** - * @typedef {Object} HTTPRequestOptions + * @typedef {object} HTTPRequestOptions * @property {httpAgent.Agent | boolean} [agent] * @property {string} [auth] * @property {Function} [createConnection] * @property {number} [defaultPort] * @property {number} [family] - * @property {Object} [headers] + * @property {object} [headers] * @property {number} [hints] * @property {string} [host] * @property {string} [hostname] diff --git a/lib/internal/errors.js b/lib/internal/errors.js index a0b87013263754..d4855e60598560 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -474,7 +474,7 @@ const captureLargerStackTrace = hideStackFrames( * The goal is to migrate them to ERR_* errors later when compatibility is * not a concern. * - * @param {Object} ctx + * @param {object} ctx * @returns {Error} */ const uvException = hideStackFrames(function uvException(ctx) { diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index 3b8d2ae158f930..3c135d3601b3cc 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -54,7 +54,7 @@ class ESMLoader { /** * Prior to ESM loading. These are called once before any modules are started. * @private - * @property {function[]} globalPreloaders First-in-first-out list of + * @property {Function[]} globalPreloaders First-in-first-out list of * preload hooks. */ #globalPreloaders = []; @@ -62,7 +62,7 @@ class ESMLoader { /** * Phase 2 of 2 in ESM loading. * @private - * @property {function[]} loaders First-in-first-out list of loader hooks. + * @property {Function[]} loaders First-in-first-out list of loader hooks. */ #loaders = [ defaultLoad, @@ -71,7 +71,7 @@ class ESMLoader { /** * Phase 1 of 2 in ESM loading. * @private - * @property {function[]} resolvers First-in-first-out list of resolver hooks + * @property {Function[]} resolvers First-in-first-out list of resolver hooks */ #resolvers = [ defaultResolve, @@ -341,8 +341,8 @@ class ESMLoader { * The internals of this WILL change when chaining is implemented, * depending on the resolution/consensus from #36954 * @param {string} url The URL/path of the module to be loaded - * @param {Object} context Metadata about the module - * @returns {Object} + * @param {object} context Metadata about the module + * @returns {object} */ async load(url, context = {}) { const defaultLoader = this.#loaders[0]; diff --git a/lib/internal/source_map/source_map.js b/lib/internal/source_map/source_map.js index fca23b0754f964..c98eb54efe4a6c 100644 --- a/lib/internal/source_map/source_map.js +++ b/lib/internal/source_map/source_map.js @@ -148,7 +148,7 @@ class SourceMap { } /** - * @return {Object} raw source map v3 payload. + * @return {object} raw source map v3 payload. */ get payload() { return cloneSourceMapV3(this.#payload); diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 4936ab761ddccb..7dae71038e5409 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -280,7 +280,7 @@ function getUserOptions(ctx, isCrossContext) { * in the best way possible given the different types. * * @param {any} value The value to print out. - * @param {Object} opts Optional options object that alters the output. + * @param {object} opts Optional options object that alters the output. */ /* Legacy: value, showHidden, depth, colors */ function inspect(value, opts) { diff --git a/lib/v8.js b/lib/v8.js index 381baaebb1f909..75981152851216 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -269,7 +269,7 @@ class DefaultSerializer extends Serializer { /** * Used to write some kind of host object, i.e. an * object that is created by native C++ bindings. - * @param {Object} abView + * @param {object} abView * @returns {void} */ _writeHostObject(abView) { diff --git a/test/async-hooks/hook-checks.js b/test/async-hooks/hook-checks.js index ba3a8d2d1d52b2..e1328810f58982 100644 --- a/test/async-hooks/hook-checks.js +++ b/test/async-hooks/hook-checks.js @@ -8,12 +8,12 @@ const assert = require('assert'); * * @name checkInvocations * @function - * @param {Object} activity including timestamps for each life time event, + * @param {object} activity including timestamps for each life time event, * i.e. init, before ... - * @param {Object} hooks the expected life time event invocations with a count + * @param {object} hooks the expected life time event invocations with a count * indicating how often they should have been invoked, * i.e. `{ init: 1, before: 2, after: 2 }` - * @param {String} stage the name of the stage in the test at which we are + * @param {string} stage the name of the stage in the test at which we are * checking the invocations */ exports.checkInvocations = function checkInvocations(activity, hooks, stage) { diff --git a/tools/eslint-rules/require-common-first.js b/tools/eslint-rules/require-common-first.js index 4096ee27710781..15a696586cbac7 100644 --- a/tools/eslint-rules/require-common-first.js +++ b/tools/eslint-rules/require-common-first.js @@ -17,8 +17,8 @@ module.exports = function(context) { /** * Function to check if the path is a module and return its name. - * @param {String} str The path to check - * @returns {String} module name + * @param {string} str The path to check + * @returns {string} module name */ function getModuleName(str) { if (str === '../common/index.mjs') { @@ -32,7 +32,7 @@ module.exports = function(context) { * Function to check if a node has an argument that is a module and * return its name. * @param {ASTNode} node The node to check - * @returns {undefined|String} module name or undefined + * @returns {undefined | string} module name or undefined */ function getModuleNameFromCall(node) { // Node has arguments and first argument is string diff --git a/tools/eslint-rules/required-modules.js b/tools/eslint-rules/required-modules.js index 06c998c7f5a182..93a5cb340edab2 100644 --- a/tools/eslint-rules/required-modules.js +++ b/tools/eslint-rules/required-modules.js @@ -27,8 +27,8 @@ module.exports = function(context) { /** * Function to check if the path is a required module and return its name. - * @param {String} str The path to check - * @returns {undefined|String} required module name or undefined + * @param {string} str The path to check + * @returns {undefined | string} required module name or undefined */ function getRequiredModuleName(str) { const match = requiredModules.find(([, test]) => { @@ -41,7 +41,7 @@ module.exports = function(context) { * Function to check if a node has an argument that is a required module and * return its name. * @param {ASTNode} node The node to check - * @returns {undefined|String} required module name or undefined + * @returns {undefined | string} required module name or undefined */ function getRequiredModuleNameFromCall(node) { // Node has arguments and first argument is string