no-thenable
March 27, 2026 · View on GitHub
📝 Disallow then property.
💼 This rule is enabled in the following configs: ✅ recommended, ☑️ unopinionated.
If an object is defined as "thenable", once it's accidentally used in an await expression, it may cause problems:
const foo = {
unicorn: 1,
then() {},
};
const {unicorn} = await foo;
console.log('after'); //<- This will never execute
const foo = {
unicorn: 1,
then() {
throw new Error('You shouldn’t have called me')
},
};
const {unicorn} = await foo;
// Error: You shouldn’t have called me
If a module has an export named then, dynamic import() may not work as expected:
// foo.js
export function then () {
throw new Error('You shouldn’t have called me')
}
// bar.js
const foo = await import('./foo.js');
// Error: You shouldn’t have called me
Examples
// ❌
export {then};
// ✅
export {then as success};
// ❌
const foo = {
then() {}
};
// ✅
const foo = {
success() {}
};
// ❌
const foo = {
get then() {}
};
// ✅
const foo = {
get success() {}
};
// ❌
foo.then = function () {}
// ✅
foo.success = function () {}
// ❌
class Foo {
then() {}
}
// ✅
class Foo {
success() {}
}
// ❌
class Foo {
static then() {}
}
// ✅
class Foo {
static success() {}
}
// ✅
const foo = bar.then;