Skip to content
← Back to rules

jsdoc/require-throws-description Style

What it does

Requires a description for @throws tags.

Why is this bad?

A @throws tag should explain the condition or reason an error may be thrown.

Examples

Examples of incorrect code for this rule:

js
/**
 * @throws {Error}
 */
function quux() {
  throw new Error("error");
}

Examples of correct code for this rule:

js
/**
 * @throws {Error} Has a description
 */
function quux() {
  throw new Error("error");
}

How to use

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

json
{
  "plugins": ["jsdoc"],
  "rules": {
    "jsdoc/require-throws-description": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["jsdoc"],
  rules: {
    "jsdoc/require-throws-description": "error",
  },
});
bash
oxlint --deny jsdoc/require-throws-description --jsdoc-plugin

Version

This rule was added in vnext.

References