oxc-project/oxc · error · OxcDiagnostic
Do not add `then` to a class.
Error message
Do not add `then` to a class.
What it means
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.
Source
Thrown at crates/oxc_linter/src/rules/unicorn/no_thenable.rs:27
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{AstNode, context::LintContext, rule::Rule};
fn object(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not add `then` to an object.")
.with_help("If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems")
.with_label(span)
}
fn export(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not export `then`.")
.with_help("If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems")
.with_label(span)
}
fn class(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not add `then` to a class.")
.with_help("If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct NoThenable;
declare_oxc_lint!(
/// ### What it does
///
/// Disallow defining a `then` property.
///
/// ### Why is this bad?
///
/// If an object is defined as "thenable", once it's accidentally
/// used in an `await` expression, it may cause problems.
///
/// ### ExamplesView on GitHub (pinned to e1e7af627c)
Solutions
- Rename the method (e.g. `thenDo`, `onFulfilled`) so instances are not thenable
- Expose the behavior via a differently named method returning a promise
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/no_thenable.rs:27 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/e588693642a230a3.
Report an issue: GitHub.