Skip to content

Commit

Permalink
fix(require-yields): check test part of if expression and check c…
Browse files Browse the repository at this point in the history
…onditionals
  • Loading branch information
brettz9 committed Jan 31, 2021
1 parent de345cf commit db001be
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/jsdocUtils.js
Expand Up @@ -747,8 +747,10 @@ const hasYieldValue = (node, checkYieldReturnValue) => {
case 'WithStatement': {
return hasYieldValue(node.body, checkYieldReturnValue);
}
case 'ConditionalExpression':
case 'IfStatement': {
return hasYieldValue(node.consequent, checkYieldReturnValue) ||
return hasYieldValue(node.test, checkYieldReturnValue) ||
hasYieldValue(node.consequent, checkYieldReturnValue) ||
hasYieldValue(node.alternate, checkYieldReturnValue);
}
case 'TryStatement': {
Expand Down
36 changes: 36 additions & 0 deletions test/rules/assertions/requireYields.js
Expand Up @@ -536,6 +536,42 @@ export default {
},
],
},
{
code: `
/**
*
*/
function * quux () {
if (yield false) {
}
}
`,
errors: [
{
line: 2,
message: 'Missing JSDoc @yields declaration.',
},
],
ignoreReadme: true,
},
{
code: `
/**
*
*/
function * quux () {
b ? yield false : true
}
`,
errors: [
{
line: 2,
message: 'Missing JSDoc @yields declaration.',
},
],
ignoreReadme: true,
},
{
code: `
/**
Expand Down

0 comments on commit db001be

Please sign in to comment.