Skip to content

Commit

Permalink
fix(require-description-complete-sentence): validate tags without nam…
Browse files Browse the repository at this point in the history
…es (e.g., beyond param/returns); fixes #333
  • Loading branch information
brettz9 committed Jul 12, 2019
1 parent d75fd6f commit 78f9b61
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/rules/requireDescriptionCompleteSentence.js
Expand Up @@ -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: {
Expand Down
14 changes: 14 additions & 0 deletions test/rules/assertions/requireDescriptionCompleteSentence.js
Expand Up @@ -500,6 +500,20 @@ export default {
}
`
},
{
code: `
/**
* @typedef {Object} Hello World
* hello world
*/
`,
errors: [
{
line: 3,
message: 'Sentence must end with a period.'
}
]
}
],
valid: [
Expand Down

0 comments on commit 78f9b61

Please sign in to comment.