← Back

jsdoc/require-returns warning

Requires returns are documented.

Will also report if multiple @returns tags are present.

Examples

❌  Incorrect

/**
 *
 */
function quux1 (foo) {

    return foo;
}
// Message: Missing JSDoc @returns declaration.

/**
 *
 */
const foo1 = () => ({
    bar: 'baz'
})
// Message: Missing JSDoc @returns declaration.

/**
 *
 */
const foo2 = bar=>({ bar })
// Message: Missing JSDoc @returns declaration.

/**
 *
 */
const foo3 = bar => bar.baz()
// Message: Missing JSDoc @returns declaration.

✅  Correct

/**
 * @returns Foo.
 */
function quux1 () {

    return foo;
}

/**
 *
 */
function quux2 () {
}

/**
 *
 */
function quux3 (bar) {
    bar.filter(baz => {
        return baz.corge();
    })
}

/**
 * @returns Array
 */
function quux4 (bar) {
    return bar.filter(baz => {
        return baz.corge();
    })
}