Skip to content

Commit

Permalink
feat(require-returns-description): avoid reporting missing descroptio…
Browse files Browse the repository at this point in the history
…ns for `Promise<void>` and `Promise<undefined>`
  • Loading branch information
brettz9 committed May 11, 2020
1 parent 548bd59 commit d855301
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .README/rules/require-returns-description.md
@@ -1,7 +1,8 @@
### `require-returns-description`

Requires that the `@returns` tag has a `description` value. The error
will not be reported if the return value is `void` or `undefined`.
will not be reported if the return value is `void` or `undefined`
or if it is `Promise<void>` or `Promise<undefined>`.

#### Options

Expand Down
17 changes: 16 additions & 1 deletion README.md
Expand Up @@ -11424,7 +11424,8 @@ function quux () {
### <code>require-returns-description</code>

Requires that the `@returns` tag has a `description` value. The error
will not be reported if the return value is `void` or `undefined`.
will not be reported if the return value is `void` or `undefined`
or if it is `Promise<void>` or `Promise<undefined>`.

<a name="eslint-plugin-jsdoc-rules-require-returns-description-options-24"></a>
#### Options
Expand Down Expand Up @@ -11547,6 +11548,20 @@ function quux () {

}

/**
* @returns {Promise<void>}
*/
function quux () {

}

/**
* @returns {Promise<undefined>}
*/
function quux () {

}

/**
* @function
* @returns
Expand Down
2 changes: 1 addition & 1 deletion src/rules/requireReturnsDescription.js
Expand Up @@ -7,7 +7,7 @@ export default iterateJsdoc(({
utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {
const type = jsdocTag.type && jsdocTag.type.trim();

if (type === 'void' || type === 'undefined') {
if (['void', 'undefined', 'Promise<void>', 'Promise<undefined>'].includes(type)) {
return;
}

Expand Down
20 changes: 20 additions & 0 deletions test/rules/assertions/requireReturnsDescription.js
Expand Up @@ -193,6 +193,26 @@ export default {
}
`,
},
{
code: `
/**
* @returns {Promise<void>}
*/
function quux () {
}
`,
},
{
code: `
/**
* @returns {Promise<undefined>}
*/
function quux () {
}
`,
},
{
code: `
/**
Expand Down

0 comments on commit d855301

Please sign in to comment.