diff --git a/README.md b/README.md index f76967b2e..f2d1ab62c 100644 --- a/README.md +++ b/README.md @@ -9572,6 +9572,14 @@ function quux () { * @property foo - Foo. */ // Options: ["never",{"tags":{"*":"always"}}] + +/** Entry point for module. + * + * @param {!Array} argv Command-line arguments. + */ +function main(argv) { +}; +// Options: ["never"] ```` diff --git a/src/rules/requireHyphenBeforeParamDescription.js b/src/rules/requireHyphenBeforeParamDescription.js index 8b5b00b6b..2c560f30f 100644 --- a/src/rules/requireHyphenBeforeParamDescription.js +++ b/src/rules/requireHyphenBeforeParamDescription.js @@ -16,7 +16,7 @@ export default iterateJsdoc(({ return; } - const startsWithHyphen = (/-/u).test(jsdocTag.description); + const startsWithHyphen = (/^\s*-/u).test(jsdocTag.description); if (always) { if (!startsWithHyphen) { report(`There must be a hyphen before @${targetTagName} description.`, (fixer) => { @@ -37,7 +37,7 @@ export default iterateJsdoc(({ } } else if (startsWithHyphen) { report(`There must be no hyphen before @${targetTagName} description.`, (fixer) => { - const [unwantedPart] = /\s*-\s*/u.exec(jsdocTag.description); + const [unwantedPart] = /^\s*-\s*/u.exec(jsdocTag.description); const replacement = sourceCode .getText(jsdocNode) diff --git a/test/rules/assertions/requireHyphenBeforeParamDescription.js b/test/rules/assertions/requireHyphenBeforeParamDescription.js index 503a7b8fd..2efc93fc4 100644 --- a/test/rules/assertions/requireHyphenBeforeParamDescription.js +++ b/test/rules/assertions/requireHyphenBeforeParamDescription.js @@ -488,5 +488,16 @@ export default { }}, ], }, + { + code: ` + /** Entry point for module. + * + * @param {!Array} argv Command-line arguments. + */ + function main(argv) { + }; + `, + options: ['never'], + }, ], };