{"record":{"id":"44345bf29afbcef8","repo":"oxc-project/oxc","slug":"avoid-using-thisarg-with-array-iteration-methods","errorCode":null,"errorMessage":"Avoid using 'thisArg' with array iteration methods","messagePattern":"Avoid using 'thisArg' with array iteration methods","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_array_method_this_argument.rs","lineNumber":15,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{Argument, CallExpression, Expression, MemberExpression},\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,\n    utils::does_expr_match_any_path,\n};\n\nfn no_array_method_this_argument_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Avoid using 'thisArg' with array iteration methods\")\n        .with_help(\"Use arrow functions or lexical scoping instead of passing 'thisArg' as a second argument to array methods like map, filter, etc.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoArrayMethodThisArgument;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallows the use of the `thisArg` parameter in array iteration methods such as\n    /// `map`, `filter`, `some`, `every`, and similar.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// The `thisArg` parameter makes code harder to understand and reason about. Instead,\n    /// prefer arrow functions or bind explicitly in a clearer way. Arrow functions inherit\n    /// `this` from the lexical scope, which is more intuitive and less error-prone.","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_array_method_this_argument.rs#L1-L33","documentation":"Raised by unicorn/no-array-method-this-argument when an array iteration method (map/filter/etc., or Array.from) is passed a `thisArg` second/third argument. The checkers (check_array_prototype_methods, check_array_from) flag the extra binding argument; the faulting input is the thisArg argument at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_array_method_this_argument.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the thisArg and capture `this` lexically inside an arrow function callback","Bind the function once outside the iteration and use the bound reference"],"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-14T00:17:10.932Z"}