{"record":{"id":"868b634737d4d695","repo":"oxc-project/oxc","slug":"do-not-assign-this-to-ident-name","errorCode":null,"errorMessage":"Do not assign `this` to `{ident_name}`","messagePattern":"Do not assign `this` to `(.+?)`","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_this_assignment.rs","lineNumber":12,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{AssignmentTarget, BindingPattern, Expression},\n};\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_this_assignment_diagnostic(span: Span, ident_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Do not assign `this` to `{ident_name}`\"))\n        .with_help(\"Reference `this` directly instead of assigning it to a variable.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoThisAssignment;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow assigning `this` to a variable.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Assigning `this` to a variable is unnecessary and confusing.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_this_assignment.rs#L1-L30","documentation":"Raised by unicorn/no-this-assignment when `this` is captured into a variable (`const self = this`) instead of using arrow functions or bind. The assigned identifier name is interpolated; the faulting input is the `this` assignment at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_this_assignment.rs:12 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reference `this` directly at the use site","Use an arrow function (which captures `this` lexically) instead of a callback that needs the saved variable","Use `.bind(this)` on the callback"],"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"}