noThenProperty
このコンテンツはまだ日本語訳がありません。
Diagnostic Category: lint/suspicious/noThenProperty
Since: v1.5.0
Sources:
- Same as:
unicorn/no-thenable
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.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:9 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not export then.
> 1 │ export {then};
│ ^^^^
2 │
code-block.js:2:5 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not add then to an object.
1 │ const foo = {
> 2 │ then() {}
│ ^^^^
3 │ };
4 │
code-block.js:2:9 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not add then to an object.
1 │ const foo = {
> 2 │ get then() {}
│ ^^^^
3 │ };
4 │
code-block.js:2:8 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not add then to an object.
1 │ const foo = {
> 2 │ get then() {}
│ ^^^^
3 │ };
4 │
code-block.js:1:1 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not add then to an object.
> 1 │ foo.then = function () {}
│ ^^^^^^^^
2 │
code-block.js:2:5 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not add then to a class.
1 │ class Foo {
> 2 │ then() {}
│ ^^^^
3 │ }
4 │
code-block.js:2:12 lint/suspicious/noThenProperty ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not add then to a class.
1 │ class Foo {
> 2 │ static then() {}
│ ^^^^
3 │ }
4 │