From 2c5e42d65053866015ab116e4d4c7897a06149f3 Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Sat, 18 May 2024 14:01:06 -0500 Subject: [PATCH] docs: [no-floating-promises] make void a more prominent option --- packages/eslint-plugin/docs/rules/no-floating-promises.mdx | 6 +++++- .../docs-eslint-output-snapshots/no-floating-promises.shot | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 9ef3c839825e..2f8d8040a875 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -17,6 +17,7 @@ Valid ways of handling a Promise-valued statement include: - `await`ing it - `return`ing it +- `void`ing it - Calling its `.then()` with two arguments - Calling its `.catch()` with one argument @@ -63,6 +64,9 @@ await promise; async function returnsPromise() { return 'value'; } + +void returnsPromise(); + returnsPromise().then( () => {}, () => {}, @@ -82,7 +86,7 @@ await Promise.all([1, 2, 3].map(async x => x + 1)); ### `ignoreVoid` -This allows you to stop the rule reporting promises consumed with void operator. +This option, which is `true` by default, allows you to stop the rule reporting promises consumed with void operator. This can be a good way to explicitly mark a promise as intentionally not awaited. Examples of **correct** code for this rule with `{ ignoreVoid: true }`: diff --git a/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-floating-promises.shot b/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-floating-promises.shot index 0dc935b52782..5c6de4ab2e0e 100644 --- a/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-floating-promises.shot +++ b/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-floating-promises.shot @@ -33,6 +33,9 @@ await promise; async function returnsPromise() { return 'value'; } + +void returnsPromise(); + returnsPromise().then( () => {}, () => {},