close

no-thenable

Configuration

rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/no-thenable': 'error',
    },
  },
]);

Rule Details

Disallow adding a then property to objects or classes, and disallow exporting a binding named then.

Objects with a then property can be treated as thenables when they are awaited. Modules with a named then export can also behave unexpectedly with dynamic import().

Computed property names are also checked when they can be statically resolved to then.

Examples of incorrect code for this rule:

const value = {
  then() {},
};

class Value {
  then() {}
}

foo.then = () => {};

export function then() {}

Examples of correct code for this rule:

const value = {
  success() {},
};

class Value {
  success() {}
}

foo.success = () => {};

export function success() {}

Original Documentation