Fix some JSDoc lint issues (#2181)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by John Gee · committed by GitHub · parent a996782 · Browse files · 7 files·+50 added−43 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+50 added−43 removed
- other:+50 added−43 removed
Provenance
- Commit
b95ea44- Tree
f8d8b50- Author
John Gee <john@ruru.gen.nz>- Committer
GitHub <noreply@github.com>- Parent
a996782
7 files changed+50 added−43 removed
modified:lib/argument.js+5 added-1 removed
48 unmodified lines4950515253535455565753 unmodified lines11111211311411511611711811912012112212312412512612712812913019 unmodified lines48 unmodified lines return this._name; }
/** * @package internal use only * @package */
_concatValue(value, previous) { if (previous === this.defaultValue || !Array.isArray(previous)) {53 unmodified lines }
/** * Make argument required. * * @returns {Argument} */ argRequired() { this.required = true; return this; }
/** * Make argument optional. * * @returns {Argument} */ argOptional() { this.required = false; return this;19 unmodified linesmodified:lib/command.js+35 added-30 removed
133 unmodified lines134 * .command('start <service>', 'start named service')135 * .command('stop [service]', 'stop named service, or all if no name supplied');136 *137 * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`138- * @param {(Object|string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)139- * @param {Object} [execOpts] - configuration options (for executable)138+ * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)139+ * @param {object} [execOpts] - configuration options (for executable)140 * @return {Command} returns new command for action handler, or `this` for executable command141 */142 143 command(nameAndArgs, actionOptsOrExecDesc, execOpts) {51 unmodified lines195 /**196 * You can customise the help by overriding Help properties using configureHelp(),197 * or with a subclass of Help by overriding createHelp().198 *199- * @param {Object} [configuration] - configuration options200- * @return {(Command|Object)} `this` command for chaining, or stored configuration199+ * @param {object} [configuration] - configuration options200+ * @return {(Command | object)} `this` command for chaining, or stored configuration201 */202 203 configureHelp(configuration) {204 if (configuration === undefined) return this._helpConfiguration;16 unmodified lines221 * getErrHelpWidth()222 * // functions based on what is being written out223 * outputError(str, write) // used for displaying errors, and not used for displaying help224 *225- * @param {Object} [configuration] - configuration options226- * @return {(Command|Object)} `this` command for chaining, or stored configuration225+ * @param {object} [configuration] - configuration options226+ * @return {(Command | object)} `this` command for chaining, or stored configuration227 */228 229 configureOutput(configuration) {230 if (configuration === undefined) return this._outputConfiguration;30 unmodified lines261 *262 * See .command() for creating an attached subcommand which inherits settings from its parent.263 *264 * @param {Command} cmd - new subcommand265- * @param {Object} [opts] - configuration options265+ * @param {object} [opts] - configuration options266 * @return {Command} `this` command for chaining267 */268 269 addCommand(cmd, opts) {316 unmodified lines586 * Check for option flag conflicts.587 * Register option if no conflicts found, or throw on conflict.588 *589 * @param {Option} option590- * @api private590+ * @private591 */592 593 _registerOption(option) {594 const matchingOption =15 unmodified lines610 * Check for command name and alias conflicts with existing commands.611 * Register command if no conflicts found, or throw on conflict.612 *613 * @param {Command} command614- * @api private614+ * @private615 */616 617 _registerCommand(command) {618 const knownBy = (cmd) => {87 unmodified lines706 707 /**708 * Internal implementation shared by .option() and .requiredOption()709 *710+ * @return {Command} `this` command for chaining711 * @private712 */713 _optionEx(config, flags, description, fn, defaultValue) {714 if (typeof flags === 'object' && flags instanceof Option) {76 unmodified lines791 * // for `.option('-f,--flag [value]'):792 * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour793 * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`794 *794- * @param {boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag.795+ * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.796+ * @return {Command} `this` command for chaining797 */798 combineFlagAndOptionalValue(combine = true) {799 this._combineFlagAndOptionalValue = !!combine;800 return this;1 unmodified line802 803 /**804 * Allow unknown options on the command line.805 *804- * @param {boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown805- * for unknown options.806+ * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.807+ * @return {Command} `this` command for chaining808 */809 allowUnknownOption(allowUnknown = true) {810 this._allowUnknownOption = !!allowUnknown;811 return this;1 unmodified line813 814 /**815 * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.816 *815- * @param {boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown816- * for excess arguments.817+ * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.818+ * @return {Command} `this` command for chaining819 */820 allowExcessArguments(allowExcess = true) {821 this._allowExcessArguments = !!allowExcess;822 return this;3 unmodified lines826 * Enable positional options. Positional means global options are specified before subcommands which lets827 * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.828 * The default behaviour is non-positional and global options may appear anywhere on the command line.829 *828- * @param {boolean} [positional=true]830+ * @param {boolean} [positional]831+ * @return {Command} `this` command for chaining832 */833 enablePositionalOptions(positional = true) {834 this._enablePositionalOptions = !!positional;835 return this;4 unmodified lines840 * so actual command-options come before command-arguments. Turning this on for a subcommand requires841 * positional options to have been enabled on the program (parent commands).842 * The default behaviour is non-positional and options may appear before or after command-arguments.843 *841- * @param {boolean} [passThrough=true]842- * for unknown options.844+ * @param {boolean} [passThrough] for unknown options.845+ * @return {Command} `this` command for chaining846 */847 passThroughOptions(passThrough = true) {848 this._passThroughOptions = !!passThrough;849 this._checkForBrokenPassThrough();40 unmodified lines890 /**891 * Retrieve option value.892 *893 * @param {string} key891- * @return {Object} value894+ * @return {object} value895 */896 897 getOptionValue(key) {898 if (this._storeOptionsAsProperties) {5 unmodified lines904 /**905 * Store option value.906 *907 * @param {string} key905- * @param {Object} value908+ * @param {object} value909 * @return {Command} `this` command for chaining910 */911 912 setOptionValue(key, value) {3 unmodified lines916 /**917 * Store option value and where the value came from.918 *919 * @param {string} key917- * @param {Object} value920+ * @param {object} value921 * @param {string} source - expected values are default/config/env/cli/implied922 * @return {Command} `this` command for chaining923 */924 127 unmodified lines1052 * program.parse(); // parse process.argv and auto-detect electron and special node flags1053 * program.parse(process.argv); // assume argv[0] is app and argv[1] is script1054 * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]1055 *1053- * @param {string[]} [argv]1054- * @param {object} [parseOptions]1055- * @param {string} parseOptions.from - one of 'node', 'user', 'electron'1056+ * @param {string[]} [argv] - optional, defaults to process.argv1057+ * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron1058+ * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'1059 * @return {Command} `this` command for chaining1060 */1061 1062 parse(argv, parseOptions) {19 unmodified lines1082 * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]1083 *1084 * @param {string[]} [argv]1085 * @param {object} [parseOptions]1083- * @param {string} parseOptions.from - one of 'node', 'user', 'electron'1086+ * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'1087 * @return {Promise}1088 */1089 1090 async parseAsync(argv, parseOptions) {97 unmodified lines1188 const signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];1189 signals.forEach((signal) => {1190 process.on(signal, () => {1191 if (proc.killed === false && proc.exitCode === null) {1192+ // @ts-ignore because signals not typed to known strings1193 proc.kill(signal);1194 }1195 });1196 });344 unmodified lines1541 /**1542 * Find matching command.1543 *1544 * @private1545+ * @return {Command | undefined}1546 */1547 _findCommand(name) {1548 if (!name) return undefined;1549 return this.commands.find(5 unmodified lines1555 * Return an option matching `arg` if any.1556 *1557 * @param {string} arg1558 * @return {Option}1554- * @package internal use only1559+ * @package1560 */1561 1562 _findOption(arg) {1563 return this.options.find((option) => option.is(arg));206 unmodified lines1770 1771 /**1772 * Return an object containing local option values as key-value pairs.1773 *1769- * @return {Object}1774+ * @return {object}1775 */1776 opts() {1777 if (this._storeOptionsAsProperties) {1778 // Preserve original behaviour so backwards compatible when still using properties13 unmodified lines1792 1793 /**1794 * Return an object containing merged local and global option values as key-value pairs.1795 *1791- * @return {Object}1796+ * @return {object}1797 */1798 optsWithGlobals() {1799 // globals overwrite locals1800 return this._getCommandAndAncestors().reduce(5 unmodified lines1806 /**1807 * Display error message and exit (or call exitOverride).1808 *1809 * @param {string} message1805- * @param {Object} [errorOptions]1810+ * @param {object} [errorOptions]1811 * @param {string} [errorOptions.code] - an id string representing the error1812 * @param {number} [errorOptions.exitCode] - used with process.exit1813 */1814 error(message, errorOptions) {270 unmodified lines2085 /**2086 * Set the description.2087 *2088 * @param {string} [str]2084- * @param {Object} [argsDescription]2089+ * @param {object} [argsDescription]2090 * @return {(string|Command)}2091 */2092 description(str, argsDescription) {2093 if (str === undefined && argsDescription === undefined)265 unmodified lines2359 * Lazy create help option.2360 * Returns null if has been disabled with .helpOption(false).2361 *2362 * @returns {(Option | null)} the help option2358- * @package internal use only2363+ * @package2364 */2365 _getHelpOption() {2366 // Lazy create help option on demand.2367 if (this._helpOption === undefined) {142 unmodified linesmodified:lib/error.js-4 removed
123345678911101112136 unmodified lines2021222326242526272832293031327 unmodified lines/** * CommanderError class * @class */class CommanderError extends Error { /** * Constructs the CommanderError class * @param {number} exitCode suggested exit code which could be used with process.exit * @param {string} code an id string representing the error * @param {string} message human-readable description of the error * @constructor */ constructor(exitCode, code, message) { super(message); // properly capture stack trace in Node.js6 unmodified lines}
/** * InvalidArgumentError class * @class */class InvalidArgumentError extends CommanderError { /** * Constructs the InvalidArgumentError class * @param {string} [message] explanation of why argument is invalid * @constructor */ constructor(message) { super(1, 'commander.invalidArgument', message); // properly capture stack trace in Node.js7 unmodified linesmodified:lib/help.js+1 added-1 removed
42 unmodified lines43 * Compare options for sort.44 *45 * @param {Option} a46 * @param {Option} b47- * @returns number47+ * @returns {number}48 */49 compareOptions(a, b) {50 const getSortKey = (option) => {51 // WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.469 unmodified linesmodified:lib/option.js+4 added-4 removed
91 unmodified lines92 * program93 * .addOption(new Option('--log', 'write logging information to file'))94 * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));95 *96- * @param {Object} impliedOptionValues96+ * @param {object} impliedOptionValues97 * @return {Option}98 */99 implies(impliedOptionValues) {100 let newImplied = impliedOptionValues;56 unmodified lines157 return this;158 }159 160 /**161- * @package internal use only161+ * @package162 */163 164 _concatValue(value, previous) {165 if (previous === this.defaultValue || !Array.isArray(previous)) {54 unmodified lines220 * Check if `arg` matches the short or long flag.221 *222 * @param {string} arg223 * @return {boolean}224- * @package internal use only224+ * @package225 */226 227 is(arg) {228 return this.short === arg || this.long === arg;4 unmodified lines233 *234 * Options are one of boolean, negated, required argument, or optional argument.235 *236 * @return {boolean}237- * @package internal use only237+ * @package238 */239 240 isBoolean() {241 return !this.required && !this.optional && !this.negate;89 unmodified linesmodified:typings/index.d.ts-2 removed
24 unmodified lines25 * Constructs the CommanderError class26 * @param exitCode - suggested exit code which could be used with process.exit27 * @param code - an id string representing the error28 * @param message - human-readable description of the error29- * @constructor29 */30 constructor(exitCode: number, code: string, message: string);31 }32 33 export class InvalidArgumentError extends CommanderError {34 /**35 * Constructs the InvalidArgumentError class36 * @param message - explanation of why argument is invalid38- * @constructor37 */38 constructor(message: string);39 }40 export { InvalidArgumentError as InvalidOptionArgumentError }; // deprecated old name934 unmodified linesmodified:eslint.config.js+5 added-1 removed
1 unmodified line2 const esLintjs = require('@eslint/js');3 const jest = require('eslint-plugin-jest');4 const tseslint = require('typescript-eslint');5 const prettier = require('eslint-config-prettier');6-//const jsdoc = require('eslint-plugin-jsdoc');6+// const jsdoc = require('eslint-plugin-jsdoc');7 8 // Only run tseslint on the files that we have included for TypeScript.9 const tsconfigTsFiles = ['**/*.{ts,mts}']; // match "include" in tsconfig.ts.json;10 const tsconfigJsFiles = ['*.{js,mjs}', 'lib/**/*.{js,mjs}']; // match "include" in tsconfig.js.json33 unmodified lines44 // 'jsdoc/tag-lines': 'off',45 // 'jsdoc/require-jsdoc': 'off',46 // 'jsdoc/require-param-description': 'off',47 // 'jsdoc/require-returns-description': 'off',48+ // 'jsdoc/require-param': ['warn', { exemptedBy: ['private'] }],49+ // // Currently can not configure checking to allow return/returns (and don't want wide change mixed with more interesting fixes),50+ // // and can not set options.jsdoc.mode yet to allow @remarks in typescript.51+ // 'jsdoc/check-tag-names': 0,52 },53 languageOptions: {54 globals: {55 ...globals.node,24 unmodified lines