Skip to content
← Back to rules

jsdoc/require-throws-type Pedantic

What it does

Requires a type on the @throws tag.

Why is this bad?

A @throws tag should document the type of error that may be thrown.

Examples

Examples of incorrect code for this rule:

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

Examples of correct code for this rule:

js
/** @throws {Error} */
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-type": "error"
  }
}
ts
import { defineConfig } from "oxlint";

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

Version

This rule was added in vnext.

References