From d5e4c8c810e54e027eccf53b14ed9e41be6dc493 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 6 Jul 2024 15:36:10 -0400 Subject: [PATCH] feat(eslint-plugin): [no-floating-promises] disable checkThenables by default for v8 --- .../docs/rules/no-floating-promises.mdx | 4 ---- .../src/rules/no-floating-promises.ts | 2 +- .../tests/rules/no-floating-promises.test.ts | 24 +++++++------------ 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 6be96809da78..bd814ac63dcd 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -129,10 +129,6 @@ await createMyThenable(); -:::info -This option is enabled by default in v7 but will be turned off by default in v8. -::: - ### `ignoreVoid` This option, which is `true` by default, allows you to stop the rule reporting promises consumed with void operator. diff --git a/packages/eslint-plugin/src/rules/no-floating-promises.ts b/packages/eslint-plugin/src/rules/no-floating-promises.ts index 4c21c6cfb18c..fe5b0a567a76 100644 --- a/packages/eslint-plugin/src/rules/no-floating-promises.ts +++ b/packages/eslint-plugin/src/rules/no-floating-promises.ts @@ -104,7 +104,7 @@ export default createRule({ { allowForKnownSafeCalls: readonlynessOptionsDefaults.allow, allowForKnownSafePromises: readonlynessOptionsDefaults.allow, - checkThenables: true, + checkThenables: false, ignoreIIFE: false, ignoreVoid: true, }, diff --git a/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts b/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts index e808d9234757..c8e860b7f257 100644 --- a/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts +++ b/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts @@ -770,15 +770,11 @@ createSafePromise(); }, ], }, - { - code: ` -declare const createPromise: () => PromiseLike; -createPromise(); - `, - options: [{ checkThenables: false }], - }, - { - code: ` + ` +declare const createPromiseLike: () => PromiseLike; +createPromiseLike(); + `, + ` interface MyThenable { then(onFulfilled: () => void, onRejected: () => void): MyThenable; } @@ -786,9 +782,7 @@ interface MyThenable { declare function createMyThenable(): MyThenable; createMyThenable(); - `, - options: [{ checkThenables: false }], - }, + `, ], invalid: [ @@ -2104,6 +2098,7 @@ async function test() { ], }, ], + options: [{ checkThenables: true }], }, { code: ` @@ -3586,6 +3581,7 @@ promise; options: [ { allowForKnownSafePromises: [{ from: 'file', name: 'SafeThenable' }], + checkThenables: true, }, ], errors: [ @@ -3962,7 +3958,6 @@ void createPromise(); ], }, ], - options: [{ checkThenables: false }], }, { code: ` @@ -3986,7 +3981,6 @@ void createMyPromise(); ], }, ], - options: [{ checkThenables: false }], }, { code: ` @@ -4014,7 +4008,7 @@ void createMyPromise(); ], }, ], - options: [{ checkThenables: false }], + options: [{ checkThenables: true }], }, ], });