oxc-project/oxc · error · OxcDiagnostic

Array destructuring may not contain consecutive ignored…

Error message

Array destructuring may not contain consecutive ignored values.

What it means

Raised by unicorn/no-unreadable-array-destructuring when a destructuring pattern contains two or more consecutive holes/elisions (`, ,`) or a spread followed by ignored holes, making the positional intent hard to read. The faulting input is the holey destructuring pattern at the labeled span.

Solutions

  1. Name the skipped elements (use descriptive identifiers instead of holes)
  2. Insert a comment placeholder element to document the skipped slot
  3. Restructure to index-based access or object destructuring when many positions are skipped
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/no_unreadable_array_destructuring.rs:10 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/1a75665e3220c6c9. Report an issue: GitHub.

Appendix: source

Thrown at crates/oxc_linter/src/rules/unicorn/no_unreadable_array_destructuring.rs:10

use oxc_allocator::ArenaVec;
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{AstNode, context::LintContext, rule::Rule};

fn no_unreadable_array_destructuring_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Array destructuring may not contain consecutive ignored values.")
        .with_label(span)
}

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

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Disallows destructuring values from an array in ways that are difficult to read.
    ///
    /// ### Why is this bad?
    ///
    /// Destructuring can be very useful, but it can also make some code harder to read.
    /// This rule prevents ignoring consecutive values (e.g. `let [,,foo] = array`)
    /// when destructuring from an array.
    ///
    /// ### Examples

View on GitHub (pinned to e1e7af627c)