Skip to content

Commit

Permalink
feat(require-description): report more precisely the action to take…
Browse files Browse the repository at this point in the history
… when "body" `descriptionStyle` is set and where user has a desc/description tag; fixes #608 (#609)
  • Loading branch information
brettz9 committed Jul 13, 2020
1 parent 6f94d12 commit 69fd79d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -7275,6 +7275,24 @@ function quux () {
// Options: [{"descriptionStyle":"body"}]
// Message: Missing JSDoc block description.
/**
* @desc Not a blank description
*/
function quux () {
}
// Options: [{"descriptionStyle":"body"}]
// Message: Remove the @desc tag to leave a plain block description or add additional description text above the @desc line.
/**
* @description Not a blank description
*/
function quux () {
}
// Options: [{"descriptionStyle":"body"}]
// Message: Remove the @description tag to leave a plain block description or add additional description text above the @description line.
/**
*
*/
Expand Down
8 changes: 7 additions & 1 deletion src/rules/requireDescription.js
Expand Up @@ -40,7 +40,13 @@ export default iterateJsdoc(({
}

if (descriptionStyle === 'body') {
report('Missing JSDoc block description.');
const descTags = utils.getPresentTags(['desc', 'description']);
if (descTags.length) {
const [{tag: tagName}] = descTags;
report(`Remove the @${tagName} tag to leave a plain block description or add additional description text above the @${tagName} line.`);
} else {
report('Missing JSDoc block description.');
}

return;
}
Expand Down
40 changes: 40 additions & 0 deletions test/rules/assertions/requireDescription.js
Expand Up @@ -60,6 +60,46 @@ export default {
},
],
},
{
code: `
/**
* @desc Not a blank description
*/
function quux () {
}
`,
errors: [
{
message: 'Remove the @desc tag to leave a plain block description or add additional description text above the @desc line.',
},
],
options: [
{
descriptionStyle: 'body',
},
],
},
{
code: `
/**
* @description Not a blank description
*/
function quux () {
}
`,
errors: [
{
message: 'Remove the @description tag to leave a plain block description or add additional description text above the @description line.',
},
],
options: [
{
descriptionStyle: 'body',
},
],
},
{
code: `
/**
Expand Down

0 comments on commit 69fd79d

Please sign in to comment.