{"record":{"id":"2a0ecaae2e4052bb","repo":"oxc-project/oxc","slug":"do-not-add-then-to-an-object","errorCode":null,"errorMessage":"Do not add `then` to an object.","messagePattern":"Do not add `then` to an object\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_thenable.rs","lineNumber":15,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{\n        Argument, ArrayExpressionElement, AssignmentExpression, AssignmentTarget, BindingPattern,\n        CallExpression, Declaration, Expression, ObjectPropertyKind, PropertyKey, match_expression,\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 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;","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_thenable.rs#L1-L33","documentation":"Raised by unicorn/no-thenable (object helper) when an object literal or assignment defines a `then` property/method, making it thenable. Thenables are assimilated by `await`/`.then()` and can cause surprising control flow; the faulting input is the `then` definition at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_thenable.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the property to something like `thenDo` or `after` so the object is not thenable","Move the callback-taking method off the object, e.g. a standalone function taking the object and a 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"}