Skip to content

Commit

Permalink
feat: make require-returns-description accept void functions (fixes #157
Browse files Browse the repository at this point in the history
)

feat: make require-returns-description accept void functions (fixes #157)
  • Loading branch information
gajus committed Mar 13, 2019
2 parents af5a9a9 + 8e9f35e commit 39918c8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -2145,6 +2145,20 @@ function quux () {
*/
function quux () {

}

/**
* @returns {undefined}
*/
function quux () {

}

/**
* @returns {void}
*/
function quux () {

}
````

Expand Down Expand Up @@ -2358,6 +2372,13 @@ function quux (bar) {
* @returns Array
*/
const quux = (bar) => bar.filter(({ corge }) => corge())

/**
* @inheritdoc
*/
function quux (foo) {
return "test"
}
````


Expand Down
6 changes: 6 additions & 0 deletions src/rules/requireReturnsDescription.js
Expand Up @@ -13,6 +13,12 @@ export default iterateJsdoc(({
});

_.forEach(jsdocTags, (jsdocTag) => {
const type = jsdocTag.type && jsdocTag.type.trim();

if (type === 'void' || type === 'undefined') {
return;
}

if (!jsdocTag.description) {
report('Missing JSDoc @' + targetTagName + ' description.', null, jsdocTag);
}
Expand Down
20 changes: 20 additions & 0 deletions test/rules/assertions/requireReturnsDescription.js
Expand Up @@ -58,6 +58,26 @@ export default {
*/
function quux () {
}
`
},
{
code: `
/**
* @returns {undefined}
*/
function quux () {
}
`
},
{
code: `
/**
* @returns {void}
*/
function quux () {
}
`
}
Expand Down

0 comments on commit 39918c8

Please sign in to comment.