From 78f9b61b3a8e0a4c9e0496d79589c288f7f7d511 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Fri, 12 Jul 2019 11:15:11 -0700 Subject: [PATCH] fix(require-description-complete-sentence): validate tags without names (e.g., beyond param/returns); fixes #333 --- src/rules/requireDescriptionCompleteSentence.js | 12 ++++++++---- .../requireDescriptionCompleteSentence.js | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/rules/requireDescriptionCompleteSentence.js b/src/rules/requireDescriptionCompleteSentence.js index 629bec052..c6542c71c 100644 --- a/src/rules/requireDescriptionCompleteSentence.js +++ b/src/rules/requireDescriptionCompleteSentence.js @@ -139,15 +139,19 @@ export default iterateJsdoc(({ validateDescription(description, report, jsdocNode, sourceCode, matchingJsdocTag); }); - const tags = jsdoc.tags.filter((tag) => { - return ['param', 'arg', 'argument', 'returns', 'return'].includes(tag.tag); - }); + const {tagsWithNames, tagsWithoutNames} = utils.getTagsByType(jsdoc.tags); - tags.some((tag) => { + tagsWithNames.some((tag) => { const description = _.trimStart(tag.description, '- '); return validateDescription(description, report, jsdocNode, sourceCode, tag); }); + + tagsWithoutNames.some((tag) => { + const description = (tag.name + ' ' + tag.description).trim(); + + return validateDescription(description, report, jsdocNode, sourceCode, tag); + }); }, { iterateAllJsdocs: true, meta: { diff --git a/test/rules/assertions/requireDescriptionCompleteSentence.js b/test/rules/assertions/requireDescriptionCompleteSentence.js index 4d7a34b74..1505f692a 100644 --- a/test/rules/assertions/requireDescriptionCompleteSentence.js +++ b/test/rules/assertions/requireDescriptionCompleteSentence.js @@ -500,6 +500,20 @@ export default { } ` + }, + { + code: ` + /** + * @typedef {Object} Hello World + * hello world + */ + `, + errors: [ + { + line: 3, + message: 'Sentence must end with a period.' + } + ] } ], valid: [