{"record":{"id":"869aaa485e54a3eb","repo":"oxc-project/oxc","slug":"passing-arg-str-as-the-deletecount-argument","errorCode":null,"errorMessage":"Passing `{arg_str}` as the `deleteCount` argument is unnecessary.","messagePattern":"Passing `(.+?)` as the `deleteCount` argument is unnecessary\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_unnecessary_array_splice_count.rs","lineNumber":17,"sourceCode":"use std::borrow::Cow;\n\nuse oxc_ast::{\n    AstKind,\n    ast::{Argument, Expression, MemberExpression, StaticMemberExpression},\n    match_member_expression,\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode, ast_util::is_method_call, context::LintContext, rule::Rule, utils::is_same_expression,\n};\n\nfn no_unnecessary_array_splice_count_diagnostic(span: Span, arg_str: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Passing `{arg_str}` as the `deleteCount` argument is unnecessary.\"\n    ))\n    .with_help(\"Omit the argument to delete all elements after the start index.\")\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoUnnecessaryArraySpliceCount;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallows passing `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#splice()` or `Array#toSpliced()`.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// When calling `Array#splice(start, deleteCount)` or `Array#toSpliced(start, skipCount)`,\n    /// omitting the `deleteCount` or `skipCount` argument will delete or skip all elements after `start`.","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_unnecessary_array_splice_count.rs#L1-L35","documentation":"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.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_unnecessary_array_splice_count.rs:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Omit the deleteCount argument when it removes nothing","Use `toSpliced()` for non-mutating edits on ES2023+ runtimes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}