Skip to content
← Back to rules

jsdoc/no-defaults Correctness

🚧 An auto-fix is planned for this rule, but not implemented at this time.

What it does ​

This rule reports defaults being used on the relevant portion of @param or @default. It also optionally reports the presence of the square-bracketed optional arguments at all.

Why is this bad? ​

The rule is intended to prevent the indication of defaults on tags where this would be redundant with ES2015 default parameters.

Examples ​

Examples of incorrect code for this rule:

javascript
/** @param {number} [foo="7"] */
function quux(foo) {}

Examples of correct code for this rule:

javascript
/** @param {number} foo */
function quux(foo) {}

/** @param foo */
function quux(foo) {}

Configuration ​

This rule accepts a configuration object with the following properties:

noOptionalParamNames ​

type: boolean

default: false

If true, report the presence of optional param names (square brackets) on @param tags.

How to use ​

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

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

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

Version ​

This rule was added in v0.3.2.

References ​