Skip to content

Commit

Permalink
fix: stop reporting for async functions with throw missing @throws;
Browse files Browse the repository at this point in the history
fixes #722

(To ensure the rejected value is documented, we may need a custom tag rule.)
  • Loading branch information
brettz9 committed Jun 19, 2021
1 parent 478b248 commit f7c8038
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -18051,6 +18051,12 @@ const itself = (n) => n;
* Not tracking on nested function
*/
const nested = () => () => {throw new Error('oops');};
/**
*/
async function foo() {
throw Error("bar");
}
````
Expand Down
2 changes: 1 addition & 1 deletion src/jsdocUtils.js
Expand Up @@ -997,7 +997,7 @@ const hasThrowValue = (node, innerFunction) => {
case 'FunctionExpression':
case 'FunctionDeclaration':
case 'ArrowFunctionExpression': {
return !innerFunction && hasThrowValue(node.body, true);
return !innerFunction && !node.async && hasThrowValue(node.body, true);
}
case 'BlockStatement': {
return node.body.some((bodyNode) => {
Expand Down
12 changes: 12 additions & 0 deletions test/rules/assertions/requireThrows.js
Expand Up @@ -418,5 +418,17 @@ export default {
const nested = () => () => {throw new Error('oops');};
`,
},
{
code: `
/**
*/
async function foo() {
throw Error("bar");
}
`,
parserOptions: {
ecmaVersion: 8,
},
},
],
};

0 comments on commit f7c8038

Please sign in to comment.