{"record":{"id":"e588693642a230a3","repo":"oxc-project/oxc","slug":"do-not-add-then-to-a-class","errorCode":null,"errorMessage":"Do not add `then` to a class.","messagePattern":"Do not add `then` to a class\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_thenable.rs","lineNumber":27,"sourceCode":"use oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn object(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Do not add `then` to an object.\")\n        .with_help(\"If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems\")\n        .with_label(span)\n}\n\nfn export(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Do not export `then`.\")\n        .with_help(\"If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems\")\n        .with_label(span)\n}\n\nfn class(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Do not add `then` to a class.\")\n        .with_help(\"If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoThenable;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow defining a `then` property.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// If an object is defined as \"thenable\", once it's accidentally\n    /// used in an `await` expression, it may cause problems.\n    ///\n    /// ### Examples","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_thenable.rs#L9-L45","documentation":"Raised by unicorn/no-thenable (class helper) when a class defines a `then` method, making its instances thenable. Any `await instance` or `.then()` use will assimilate it unexpectedly; the faulting input is the `then` member definition at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_thenable.rs:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the method (e.g. `thenDo`, `onFulfilled`) so instances are not thenable","Expose the behavior via a differently named method returning a promise"],"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"}