oxc-project/oxc · error · OxcDiagnostic

Defaults are not permitted.

Error message

Defaults are not permitted.

What it means

Fires from jsdoc/no-defaults when a documented function parameter carries a default value in its signature while the rule forbids documenting/permitting defaults. The run visitor finds the nearest JSDoc node for the function and the helper attaches the rule's contextual help text.

Source

Thrown at crates/oxc_linter/src/rules/jsdoc/no_defaults.rs:16

use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use schemars::JsonSchema;
use serde::Deserialize;

use crate::{
    AstNode,
    context::LintContext,
    rule::{DefaultRuleConfig, Rule},
    utils::{get_function_nearest_jsdoc_node, should_ignore_as_internal, should_ignore_as_private},
};

fn no_defaults_diagnostic(span: Span, x1: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn("Defaults are not permitted.").with_help(x1.to_string()).with_label(span)
}

#[derive(Debug, Default, Clone, Deserialize)]
pub struct NoDefaults(Box<NoDefaultsConfig>);

declare_oxc_lint!(
    /// ### 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
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the default value from the parameter signature
  2. Wrap the parameter in an options object if optional behavior is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/jsdoc/no_defaults.rs:16 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/9b16bf03144006cf. Report an issue: GitHub.