Skip to content

Commit

Permalink
fix(require-returns): async with return should be documented; fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed May 18, 2020
1 parent 176be5d commit 99476af
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
15 changes: 8 additions & 7 deletions README.md
Expand Up @@ -12209,6 +12209,14 @@ class quux {
}
// Options: [{"contexts":["any"],"forceRequireReturn":true}]
// Message: Missing JSDoc @returns declaration.
/**
* @param {array} a
*/
async function foo(a) {
return Promise.all(a);
}
// Message: Missing JSDoc @returns declaration.
````
The following patterns are not considered problems:
Expand Down Expand Up @@ -12487,13 +12495,6 @@ function quux () {
}
// Options: [{"exemptedBy":["type"]}]
/**
* @param {array} a
*/
async function foo(a) {
return Promise.all(a);
}
/**
* @param {array} a
*/
Expand Down
2 changes: 1 addition & 1 deletion src/rules/requireReturns.js
Expand Up @@ -88,7 +88,7 @@ export default iterateJsdoc(({
return true;
}

return !isAsync && iteratingFunction && utils.hasReturnValue();
return iteratingFunction && utils.hasReturnValue();
};

if (shouldReport()) {
Expand Down
32 changes: 19 additions & 13 deletions test/rules/assertions/requireReturns.js
Expand Up @@ -529,6 +529,25 @@ export default {
forceRequireReturn: true,
}],
},
{
code: `
/**
* @param {array} a
*/
async function foo(a) {
return Promise.all(a);
}
`,
errors: [
{
line: 2,
message: 'Missing JSDoc @returns declaration.',
},
],
parserOptions: {
ecmaVersion: 8,
},
},
],
valid: [
{
Expand Down Expand Up @@ -963,19 +982,6 @@ export default {
},
],
},
{
code: `
/**
* @param {array} a
*/
async function foo(a) {
return Promise.all(a);
}
`,
parserOptions: {
ecmaVersion: 8,
},
},
{
code: `
/**
Expand Down

0 comments on commit 99476af

Please sign in to comment.