Skip to content

unicorn/no-thenable Correctness

This rule is turned on by default.

What it does

disallow 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:

Example

javascript
async function example() {
  const foo = {
    unicorn: 1,
    then() {},
  };

  const { unicorn } = await foo;

  console.log("after"); //<- This will never execute
}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny unicorn/no-thenable
json
{
  "rules": {
    "unicorn/no-thenable": "error"
  }
}

References

Released under the MIT License.