Requires a return statement (or non-undefined
Promise resolve value) in
function bodies if a @returns
tag (without a void
or undefined
type)
is specified in the function's jsdoc comment.
Will also report @returns {void}
and @returns {undefined}
if exemptAsync
is set to false
no non-undefined
returned or resolved value is found.
Will also report if multiple @returns
tags are present.
exemptGenerators
- Because a generator might be labeled as having aIterableIterator
@returns
value (along with an iterator type corresponding to the type of anyyield
statements), projects might wish to leverage@returns
in generators even without areturn
statement. This option is thereforetrue
by default intypescript
mode (in "jsdoc" mode, one might be more likely to take advantage of@yields
). Set it tofalse
if you wish for a missingreturn
to be flagged regardless.exemptAsync
- By default, functions which return aPromise
that are not detected as resolving with a non-undefined
value andasync
functions (even ones that do not explicitly return a value, as these are returning aPromise
implicitly) will be exempted from reporting by this rule. If you wish to insist that onlyPromise
's which resolve to non-undefined
values orasync
functions with explicitreturn
's will be exempted from reporting (i.e., thatasync
functions can be reported if they lack an explicit (non-undefined
)return
when a@returns
is present), you can setexemptAsync
tofalse
on the options object.reportMissingReturnForUndefinedTypes
- Iftrue
and no return or resolve value is found, this setting will even insist that reporting occur withvoid
orundefined
(including as an indicatedPromise
type). Unlikerequire-returns
, with this option in the rule, one can discourage the labeling ofundefined
types. Defaults tofalse
.
Context | ArrowFunctionExpression , FunctionDeclaration , FunctionExpression |
Tags | returns |
Aliases | return |
Options | exemptAsync , reportMissingReturnForUndefinedTypes |
Recommended | true |