{"record":{"id":"3104b6625b9bc102","repo":"oxc-project/oxc","slug":"do-not-use-arguments-method-name","errorCode":null,"errorMessage":"Do not use `arguments.{method_name}`.","messagePattern":"Do not use `arguments\\.(.+?)`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_caller.rs","lineNumber":9,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_caller_diagnostic(span: Span, method_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Do not use `arguments.{method_name}`.\"))\n        .with_help(\"`caller`, `callee`, and `arguments` properties may not be accessed on strict mode functions or the arguments objects for calls to them.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoCaller;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow the use of `arguments.caller` or `arguments.callee`.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// The use of `arguments.caller` and `arguments.callee` make several code\n    /// optimizations impossible. They have been deprecated in JavaScript, and\n    /// their use is forbidden while in strict mode.\n    ///","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_caller.rs#L1-L27","documentation":"Diagnostic from the oxlint rule `no-caller` (crates/oxc_linter/src/rules/eslint/no_caller.rs). It reports access to `arguments.caller` or `arguments.callee` (the message template says `arguments.{method_name}`). Both properties are deprecated, unstandardized, and restricted in ES5 strict mode — accessing them on strict-mode functions or their arguments objects throws a TypeError at runtime, and they block engine optimizations like inlining.","triggerScenarios":"A StaticMemberExpression whose object is the identifier `arguments` and whose property name is `caller` or `callee` — e.g. `arguments.callee()`, `const f = arguments.caller;` — including function expressions named via `arguments.callee` for recursion.","commonSituations":"Old recursive anonymous function expressions (pre-ES5 idiom `function() { ... arguments.callee ... }`); minified or transpiled legacy bundles re-linted with oxlint; code copied from old snippets into a strict-mode ESM file where the access would actually throw.","solutions":["Give the function a name and recurse via that name instead of `arguments.callee`.","Replace `arguments` entirely with a rest parameter (`function f(...args)`) so there is no arguments object to reach into.","If you need the calling context, restructure to pass an explicit callback/context argument instead of reading `arguments.caller`.","As a last resort for machine-generated legacy code, suppress with `// oxlint-disable-next-line no-caller`."],"exampleFix":"// before\nconst factorial = function (n) {\n  return n <= 1 ? 1 : n * arguments.callee(n - 1);\n};\n\n// after\nconst factorial = function fact(n) {\n  return n <= 1 ? 1 : n * fact(n - 1);\n};","handlingStrategy":"type-guard","validationCode":"// Detect legacy callee/caller usage before lint/strict-mode runtime failures\nconst usesArgumentsIntrospection = /arguments\\s*\\.\\s*(callee|caller)/.test(src);\nif (usesArgumentsIntrospection) block('legacy arguments introspection found');","typeGuard":null,"tryCatchPattern":"// If you must run untrusted legacy code that may touch arguments.caller:\ntry {\n  legacy();\n} catch (e) {\n  if (e instanceof TypeError && /callee|caller/.test(e.message)) {\n    // strict-mode access; route to the named-function rewrite\n  } else throw e;\n}","preventionTips":["Always name function expressions so recursion never needs arguments.callee.","Use rest parameters (...args) in all new code.","Run oxlint with the eslint correctness category to catch these before strict mode throws."],"tags":["lint","deprecated-api","strict-mode","arguments-object","oxlint"],"backgroundTag":"arguments-callee-caller","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"}