oxc-project/oxc · error · OxcDiagnostic

Passing `1` as the `depth` argument is unnecessary.

Error message

Passing `1` as the `depth` argument is unnecessary.

What it means

Raised by unicorn/no-unnecessary-array-flat-depth when `Array#flat` is called with `1` as the depth argument, since 1 is the default depth. The faulting input is the explicit `1` argument at the labeled span; the fix removes it.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/no_unnecessary_array_flat_depth.rs:11

use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};

use crate::{
    AstNode, ast_util::is_method_call, context::LintContext, fixer::RuleFixer, rule::Rule,
};

fn no_unnecessary_array_flat_depth_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Passing `1` as the `depth` argument is unnecessary.")
        .with_help("Remove the argument")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct NoUnnecessaryArrayFlatDepth;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Disallows passing `1` to `Array.prototype.flat`.
    ///
    /// ### Why is this bad?
    ///
    /// Passing `1` is unnecessary.
    ///
    /// ### Examples
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the `1` argument: `array.flat()`
  2. Pass the actually intended depth if deeper flattening was meant
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/no_unnecessary_array_flat_depth.rs:11 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/5c26139649aefba9. Report an issue: GitHub.