{"record":{"id":"134229e0a82cbda5","repo":"oxc-project/oxc","slug":"passing-arg-str-as-the-end-argument-is-unnec","errorCode":null,"errorMessage":"Passing `{arg_str}` as the `end` argument is unnecessary.","messagePattern":"Passing `(.+?)` as the `end` argument is unnecessary\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_unnecessary_slice_end.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_slice_end_diagnostic(span: Span, arg_str: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Passing `{arg_str}` as the `end` argument is unnecessary.\"))\n        .with_help(\"Consider omitting the unnecessary end argument.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoUnnecessarySliceEnd;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallows unnecessarily passing a second argument to `slice(...)`, for\n    /// cases where it would not change the result.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// When using `.slice(...)` without a second argument, the second argument\n    /// defaults to the object's length. As such, passing the length explicitly\n    /// - or using `Infinity` - is unnecessary.","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_unnecessary_slice_end.rs#L1-L35","documentation":"Raised by unicorn/no-unnecessary-slice-end when `Array#slice`'s `end` argument is redundant (e.g. `array.length` or an out-of-bounds value equal to the default). The argument source text is interpolated; the faulting input is the redundant end argument at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_unnecessary_slice_end.rs:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Omit the `end` argument so slicing runs to the end of the array","Pass the intended exclusive index if truncation was actually meant"],"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"}