oxc-project/oxc · error · OxcDiagnostic
Passing `{arg_str}` as the `deleteCount` argument is unneces
Error message
Passing `{arg_str}` as the `deleteCount` argument is unnecessary. What it means
Raised by unicorn/no-unnecessary-array-splice-count when `Array#splice` is passed a deleteCount that provably deletes no elements (e.g. `0` or a value equal to the remaining length). The argument source text is interpolated; the faulting input is the redundant deleteCount argument at the labeled span.
Source
Thrown at crates/oxc_linter/src/rules/unicorn/no_unnecessary_array_splice_count.rs:17
use std::borrow::Cow;
use oxc_ast::{
AstKind,
ast::{Argument, Expression, MemberExpression, StaticMemberExpression},
match_member_expression,
};
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, rule::Rule, utils::is_same_expression,
};
fn no_unnecessary_array_splice_count_diagnostic(span: Span, arg_str: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"Passing `{arg_str}` as the `deleteCount` argument is unnecessary."
))
.with_help("Omit the argument to delete all elements after the start index.")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct NoUnnecessaryArraySpliceCount;
declare_oxc_lint!(
/// ### What it does
///
/// Disallows passing `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#splice()` or `Array#toSpliced()`.
///
/// ### Why is this bad?
///
/// When calling `Array#splice(start, deleteCount)` or `Array#toSpliced(start, skipCount)`,
/// omitting the `deleteCount` or `skipCount` argument will delete or skip all elements after `start`.View on GitHub (pinned to e1e7af627c)
Solutions
- Omit the deleteCount argument when it removes nothing
- Use `toSpliced()` for non-mutating edits on ES2023+ runtimes
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/no_unnecessary_array_splice_count.rs:17 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/869aaa485e54a3eb.
Report an issue: GitHub.