-
-
Notifications
You must be signed in to change notification settings - Fork 170
Closed
Description
Expected behavior
jsdoc/require-returns-check should not produce a warning or error for functions with @returns types which include undefined.
Actual behavior
The following warning is produced:
1:1 warning JSDoc @returns declaration present but return expression not available in function jsdoc/require-returns-check
ESLint Config
{
"extends": [
"plugin:jsdoc/recommended"
]
}ESLint sample
/** Maybe return a boolean.
*
* @returns {boolean|undefined} true, or undefined.
*/
function maybeTrue() {
if (Math.random() > 0.5) {
return true;
}
}Environment
- Node version: v18.10.0
- ESLint version v8.26.0
eslint-plugin-jsdocversion: 39.3.22
Related Issues
Additional Notes
I noticed the same issue occurs with @returns {boolean=}, but I'm not sure whether = is allowed in @returns types. It's only documented to signify optional parameters, not optional return values, as far as I can see.