Skip to content

Commit 696d048

Browse files
committed
fix(require-returns): don't report with forceRequireReturn when tag is explicitly undefined/void
If there is a force require return setting, we only want to reject on a lack of a returns tag, not a function with an explicit `@returns {undefined}`
1 parent 27be21f commit 696d048

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/rules/requireReturns.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ export default iterateJsdoc(({
6464
}
6565

6666
// In case the code returns something, we expect a return value in JSDoc.
67-
if (!utils.hasDefinedTypeReturnTag(tags[0]) && (
68-
utils.isForceRequireReturn() || utils.hasReturnValue()
69-
)) {
67+
const [tag] = tags;
68+
if (!utils.hasDefinedTypeReturnTag(tag) && utils.hasReturnValue() ||
69+
(typeof tag === 'undefined' || tag === null) && utils.isForceRequireReturn()
70+
) {
7071
report('Missing JSDoc @' + tagName + ' declaration.');
7172
}
7273
}, {

test/rules/assertions/requireReturns.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,20 @@ export default {
408408
}
409409
}
410410
`
411+
},
412+
{
413+
code: `
414+
/**
415+
* @returns {void}
416+
*/
417+
function quux () {
418+
}
419+
`,
420+
settings: {
421+
jsdoc: {
422+
forceRequireReturn: true
423+
}
424+
}
411425
}
412426
]
413427
};

0 commit comments

Comments
 (0)