Skip to content

Commit 5c8a011

Browse files
committed
fix(require-returns): Ensure that @returns {undefined} tags with return undefined are not reported
1 parent 2605705 commit 5c8a011

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

src/rules/requireReturns.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ export default iterateJsdoc(({
6565

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

test/rules/assertions/requireReturns.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,70 @@ export default {
422422
forceRequireReturn: true
423423
}
424424
}
425+
},
426+
{
427+
code: `
428+
/**
429+
* @returns {void}
430+
*/
431+
function quux () {
432+
return undefined;
433+
}
434+
`
435+
},
436+
{
437+
code: `
438+
/**
439+
* @returns {void}
440+
*/
441+
function quux () {
442+
return undefined;
443+
}
444+
`,
445+
settings: {
446+
jsdoc: {
447+
forceRequireReturn: true
448+
}
449+
}
450+
},
451+
{
452+
code: `
453+
/**
454+
* @returns {void}
455+
*/
456+
function quux () {
457+
return;
458+
}
459+
`
460+
},
461+
{
462+
code: `
463+
/**
464+
* @returns {void}
465+
*/
466+
function quux () {
467+
}
468+
`,
469+
settings: {
470+
jsdoc: {
471+
forceRequireReturn: true
472+
}
473+
}
474+
},
475+
{
476+
code: `
477+
/**
478+
* @returns {void}
479+
*/
480+
function quux () {
481+
return;
482+
}
483+
`,
484+
settings: {
485+
jsdoc: {
486+
forceRequireReturn: true
487+
}
488+
}
425489
}
426490
]
427491
};

0 commit comments

Comments
 (0)