Skip to content

jsdoc/require-returns Pedantic

What it does

Requires that return statements are documented. Will also report if multiple @returns tags are present.

Why is this bad?

The rule is intended to prevent the omission of @returns tag when necessary.

Examples

Examples of incorrect code for this rule:

javascript
/** Foo. */
function quux() {
  return foo;
}

/**
 * @returns Foo!
 * @returns Foo?
 */
function quux() {
  return foo;
}

Examples of correct code for this rule:

javascript
/** @returns Foo. */
function quux() {
  return foo;
}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny jsdoc/require-returns --jsdoc-plugin
json
{
  "plugins": ["jsdoc"],
  "rules": {
    "jsdoc/require-returns": "error"
  }
}

References

Released under the MIT License.