{"record":{"id":"3afaa2d3c5ecd96d","repo":"oxc-project/oxc","slug":"disallow-recursive-access-to-this-within-kind","errorCode":null,"errorMessage":"Disallow recursive access to `this` within {kind}.","messagePattern":"Disallow recursive access to `this` within (.+?)\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_accessor_recursion.rs","lineNumber":19,"sourceCode":"use oxc_ast::{\n    AstKind, MemberExpressionKind,\n    ast::{\n        BindingPattern, MethodDefinition, MethodDefinitionKind, ObjectProperty, PropertyKey,\n        PropertyKind, UpdateExpression,\n    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_accessor_recursion_diagnostic(span: Span, kind: &str) -> OxcDiagnostic {\n    let method_kind = match kind {\n        \"setters\" => \"set\",\n        _ => \"get\",\n    };\n    OxcDiagnostic::warn(format!(\"Disallow recursive access to `this` within {kind}.\"))\n        .with_help(format!(\n            \"Remove this property access, or remove `{method_kind}` from the method\"\n        ))\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoAccessorRecursion;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow recursive access to `this` within getters and setters.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// This rule prevents recursive access to `this` within getter and\n    /// setter methods in objects and classes, avoiding infinite recursion","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_accessor_recursion.rs#L1-L37","documentation":"Raised by unicorn/no-accessor-recursion when a getter or setter reads or writes the same property it defines via `this`, creating infinite recursion. The helper maps the configured accessor kind to 'get'/'set' for the message; the faulting input is the `this.prop` access inside the accessor at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_accessor_recursion.rs:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Store the value in a separate private field or closure variable instead of the accessor's own property","In setters, guard against self-assignment or delegate to an internal backing property","Rearchitect the accessor so it does not trigger itself"],"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"}