{"record":{"id":"1001eef712bf29d1","repo":"oxc-project/oxc","slug":"prefer-reflect-apply-over-function-apply","errorCode":null,"errorMessage":"Prefer `Reflect.apply()` over `Function#apply()`.","messagePattern":"Prefer `Reflect\\.apply\\(\\)` over `Function#apply\\(\\)`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/prefer_reflect_apply.rs","lineNumber":17,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{Argument, Expression, MemberExpression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    fixer::{RuleFix, RuleFixer},\n    rule::Rule,\n};\n\nfn prefer_reflect_apply_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Prefer `Reflect.apply()` over `Function#apply()`.\")\n        .with_help(\"`Reflect.apply()` is less verbose and easier to understand.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferReflectApply;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallows the use of `Function.prototype.apply()` and suggests using `Reflect.apply()` instead.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// `Reflect.apply()` is arguably less verbose and easier to understand.\n    /// In addition, when you accept arbitrary methods,\n    /// it's not safe to assume `.apply()` exists or is not overridden.\n    ///","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/prefer_reflect_apply.rs#L1-L35","documentation":"Emitted by the unicorn/prefer-reflect-apply rule at a `Function.prototype.apply` call site (e.g. `fn.apply(this, args)`). It flags the member-call form because `Reflect.apply(fn, thisArg, args)` expresses the same operation more directly and is considered less verbose and clearer.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/prefer_reflect_apply.rs:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rewrite `fn.apply(thisArg, args)` as `Reflect.apply(fn, thisArg, args)`","The rule supplies an automatic fix to `Reflect.apply()`"],"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"}