src/content/docs/linter/rules/no-then-property.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.5.0` - Diagnostic Category: [`lint/suspicious/noThenProperty`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`unicorn/no-thenable`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-thenable.md){
"linter": {
"rules": {
"suspicious": {
"noThenProperty": "error"
}
}
}
}
Disallow then property.
When combining objects with a then method (thenable objects) with await expressions or dynamic imports, caution is necessary.
These syntaxes interpret the object's then method as intended for the resolution or rejection of a promise, which can lead to unexpected behavior or errors.
export {then};
const foo = {
then() {}
};
const foo = {
get then() {}
};
const foo = {
get then() {}
};
foo.then = function () {}
class Foo {
then() {}
}
class Foo {
static then() {}
}
export {then as success};
const foo = {
success() {}
};
class Foo {
success() {}
}
const foo = bar.then;