Skip to content

noThenProperty

biome.json
{
"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};
code-block.js:1:9 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This export exposes the name then.

> 1 │ export {then};
^^^^
2 │

Values with a then property can be treated like promises by await and dynamic imports, which can cause unexpected behavior.

Export this value under a different name, or rename the declaration so it does not expose then.

const foo = {
then() {}
};
code-block.js:2:5 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This object defines a then property.

1 │ const foo = {
> 2 │ then() {}
^^^^
3 │ };
4 │

Values with a then property can be treated like promises by await and dynamic imports, which can cause unexpected behavior.

Rename this property to something other than then unless you intentionally need a thenable object.

const foo = {
get then() {}
};
code-block.js:2:9 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This object defines a then property.

1 │ const foo = {
> 2 │ get then() {}
^^^^
3 │ };
4 │

Values with a then property can be treated like promises by await and dynamic imports, which can cause unexpected behavior.

Rename this property to something other than then unless you intentionally need a thenable object.

const foo = {
get then() {}
};
code-block.js:2:8 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This object defines a then property.

1 │ const foo = {
> 2 │ get then() {}
^^^^
3 │ };
4 │

Values with a then property can be treated like promises by await and dynamic imports, which can cause unexpected behavior.

Rename this property to something other than then unless you intentionally need a thenable object.

foo.then = function () {}
code-block.js:1:1 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This object defines a then property.

> 1 │ foo.then = function () {}
^^^^^^^^
2 │

Values with a then property can be treated like promises by await and dynamic imports, which can cause unexpected behavior.

Rename this property to something other than then unless you intentionally need a thenable object.

class Foo {
then() {}
}
code-block.js:2:5 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This class defines a then member.

1 │ class Foo {
> 2 │ then() {}
^^^^
3 │ }
4 │

Values with a then property can be treated like promises by await and dynamic imports, which can cause unexpected behavior.

Rename this member to something other than then unless you intentionally need a thenable class.

class Foo {
static then() {}
}
code-block.js:2:12 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This class defines a then member.

1 │ class Foo {
> 2 │ static then() {}
^^^^
3 │ }
4 │

Values with a then property can be treated like promises by await and dynamic imports, which can cause unexpected behavior.

Rename this member to something other than then unless you intentionally need a thenable class.

export {then as success};
const foo = {
success() {}
};
class Foo {
success() {}
}
const foo = bar.then;