{"record":{"id":"61839a66f2220a54","repo":"oxc-project/oxc","slug":"unexpected-aliasing-of-members-of-this-to-local","errorCode":null,"errorMessage":"Unexpected aliasing of members of 'this' to local variables.","messagePattern":"Unexpected aliasing of members of 'this' to local variables\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/typescript/no_this_alias.rs","lineNumber":26,"sourceCode":"use oxc_str::CompactStr;\nuse rustc_hash::FxHashSet;\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_this_alias_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected aliasing of 'this' to local variable.\")\n        .with_help(\"Assigning a variable to this instead of properly using arrow lambdas may be a symptom of pre-ES2015 practices or not managing scope well.\")\n        .with_label(span)\n}\n\nfn no_this_destructure_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected aliasing of members of 'this' to local variables.\")\n        .with_help(\n            \"Disabling destructuring of this is not a default, consider allowing destructuring\",\n        )\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct NoThisAlias(Box<NoThisAliasConfig>);\n\n#[derive(Debug, Clone, JsonSchema, Serialize, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoThisAliasConfig {\n    /// Whether to allow destructuring of `this` to local variables.\n    allow_destructuring: bool,\n    /// An array of variable names that are allowed to alias `this`.\n    #[serde(alias = \"allowNames\")]\n    // Note: allowedNames is the config option used in the original ESLint rule, we typo'd it as allowNames.\n    allowed_names: FxHashSet<CompactStr>,","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/no_this_alias.rs#L8-L44","documentation":"Raised by typescript/no_this_alias when destructuring from `this` into local variables (e.g. `const { a, b } = this;`). At the throw site members of `this` are detached into locals — the plural form of the this-aliasing pattern — which snapshot mutable instance state at that instant and can desynchronize from the instance; the rule directs authors to keep member access explicit or use arrow functions. no_this_destructure_diagnostic fires from run() on destructuring declarations whose right side is `this`.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/typescript/no_this_alias.rs:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Access members directly through this.x instead of destructuring.","Enable allowDestructuring in rule options if this pattern is acceptable."],"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"}