From 5a33bbe0b6d8d5223f319242d3d9e4d810182eab Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sat, 7 Sep 2024 00:48:10 +0200 Subject: [PATCH 01/14] Improved no-floating-promises documentation --- .../docs/rules/no-floating-promises.mdx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 18a84c2e0240..3a8da7ed56a3 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -13,13 +13,13 @@ A "floating" Promise is one that is created without any code set up to handle an Floating Promises can cause several issues, such as improperly sequenced operations, ignored Promise rejections, and more. This rule reports when a Promise is created and not properly handled. -Valid ways of handling a Promise-valued statement include: +Valid ways of silencing 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 +- `await`ing it (❌ unhandled) +- `return`ing it (❌ unhandled) +- [`void`ing it](#ignorevoid) (❌ unhandled) +- Calling its `.then()` with two arguments (✅ handled) +- Calling its `.catch()` with one argument (✅ handled) This rule also reports when an Array containing Promises is created and not properly handled. The main way to resolve this is by using one of the Promise concurrency methods to create a single Promise, then handling that according to the procedure above. These methods include: @@ -134,6 +134,12 @@ await createMyThenable(); 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. +:::warning +Voiding a Promise doesn't handle it, but just ignores the outcome. Such Promise rejection will still lead to an +[`unhandledrejection` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) +being fired and error logs being printed. Refer to the list at the top of the page for the possible ways to handle a promise. +::: + Examples of **correct** code for this rule with `{ ignoreVoid: true }`: ```ts option='{ "ignoreVoid": true }' showPlaygroundButton From e65bd7b380b9dc6d8ef20ed84bfa73b2a44fd72d Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Mon, 9 Sep 2024 13:20:10 +0200 Subject: [PATCH 02/14] Changed silencing phrase --- packages/eslint-plugin/docs/rules/no-floating-promises.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index f0127d89a3fa..8360ea8dc16e 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -12,8 +12,7 @@ import TabItem from '@theme/TabItem'; A "floating" Promise is one that is created without any code set up to handle any errors it might throw. Floating Promises can cause several issues, such as improperly sequenced operations, ignored Promise rejections, and more. -This rule reports when a Promise is created and not properly handled. -Valid ways of silencing a Promise-valued statement include: +This rule will report Promise-valued statements that are not treated in one of the following ways: - `await`ing it (❌ unhandled) - `return`ing it (❌ unhandled) From a68205bee959d1ccbe4175c5dd3f01e75e619fc6 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Mon, 9 Sep 2024 13:21:49 +0200 Subject: [PATCH 03/14] Moved rules report order to prioritize handling --- packages/eslint-plugin/docs/rules/no-floating-promises.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 8360ea8dc16e..44ac14efa9dd 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -14,11 +14,11 @@ Floating Promises can cause several issues, such as improperly sequenced operati This rule will report Promise-valued statements that are not treated in one of the following ways: +- Calling its `.then()` with two arguments (✅ handled) +- Calling its `.catch()` with one argument (✅ handled) - `await`ing it (❌ unhandled) - `return`ing it (❌ unhandled) - [`void`ing it](#ignorevoid) (❌ unhandled) -- Calling its `.then()` with two arguments (✅ handled) -- Calling its `.catch()` with one argument (✅ handled) This rule also reports when an Array containing Promises is created and not properly handled. The main way to resolve this is by using one of the Promise concurrency methods to create a single Promise, then handling that according to the procedure above. These methods include: From a1c35cdb0f78b1d4b7f7de138b3426d4bfed61c8 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Mon, 9 Sep 2024 13:59:26 +0200 Subject: [PATCH 04/14] Improved ignoreVoid warning --- .../docs/rules/no-floating-promises.mdx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 44ac14efa9dd..85f9a2216b6d 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -134,9 +134,15 @@ This option, which is `true` by default, allows you to stop the rule reporting p This can be a good way to explicitly mark a promise as intentionally not awaited. :::warning -Voiding a Promise doesn't handle it, but just ignores the outcome. Such Promise rejection will still lead to an -[`unhandledrejection` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) -being fired and error logs being printed. Refer to the list at the top of the page for the possible ways to handle a promise. +Voiding a Promise doesn't handle it or change the runtime behavior. The outcome is just ignored, like disabling the rule with a + +``` +// eslint-disable-next-line @typescript-eslint/no-floating-promises +``` + +Such Promise rejection will still lead to an [`unhandledrejection` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) +being fired and error logs being printed. Refer to MDN's [_Using Promises (error handling)_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling) +to learn how to handle correctly a promise. ::: Examples of **correct** code for this rule with `{ ignoreVoid: true }`: From a3e97b9c2d47053a0fd817c38ff533e2ebdc31c5 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Mon, 9 Sep 2024 14:01:09 +0200 Subject: [PATCH 05/14] Removed handled/unhandled markers and added a bit on the next tip --- .../docs/rules/no-floating-promises.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 85f9a2216b6d..37cf41f1313e 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -14,11 +14,11 @@ Floating Promises can cause several issues, such as improperly sequenced operati This rule will report Promise-valued statements that are not treated in one of the following ways: -- Calling its `.then()` with two arguments (✅ handled) -- Calling its `.catch()` with one argument (✅ handled) -- `await`ing it (❌ unhandled) -- `return`ing it (❌ unhandled) -- [`void`ing it](#ignorevoid) (❌ unhandled) +- Calling its `.then()` with two arguments +- Calling its `.catch()` with one argument +- `await`ing it +- `return`ing it +- [`void`ing it](#ignorevoid) This rule also reports when an Array containing Promises is created and not properly handled. The main way to resolve this is by using one of the Promise concurrency methods to create a single Promise, then handling that according to the procedure above. These methods include: @@ -28,7 +28,7 @@ This rule also reports when an Array containing Promises is created and not prop - `Promise.race()` :::tip -`no-floating-promises` only detects unhandled Promise _statements_. +`no-floating-promises` only detects unhandled Promise _statements_ and voided ones. See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements. ::: From 628b753189e61a209f8dc7653362f07a0994d7c6 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Mon, 9 Sep 2024 19:20:12 +0200 Subject: [PATCH 06/14] Reverted tip edit --- packages/eslint-plugin/docs/rules/no-floating-promises.mdx | 2 +- 1 file changed, 1 insertion(+), 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 37cf41f1313e..3a3e689aef16 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -28,7 +28,7 @@ This rule also reports when an Array containing Promises is created and not prop - `Promise.race()` :::tip -`no-floating-promises` only detects unhandled Promise _statements_ and voided ones. +`no-floating-promises` only detects unhandled Promise _statements_. See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements. ::: From dc61f8ff3f1732ef066720e6c7cd1c39f65c66d2 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 10 Sep 2024 08:18:29 +0200 Subject: [PATCH 07/14] Added a paragraph about promises handling and improved the warning in ignoreVoid --- .../docs/rules/no-floating-promises.mdx | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 3a3e689aef16..658905503d56 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -27,6 +27,8 @@ This rule also reports when an Array containing Promises is created and not prop - `Promise.any()` - `Promise.race()` +Refer to [Handling Promises Rejections](#handling-promises-rejections) below for more information about this rule. + :::tip `no-floating-promises` only detects unhandled Promise _statements_. See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements. @@ -81,6 +83,24 @@ await Promise.all([1, 2, 3].map(async x => x + 1)); +## Handling Promises rejections + +Javascript doesn't know the concept of a function that cannot throw as well as of a Promise that cannot be rejected. +Attempting to handling a Promise rejection in important to attempt preventing unexpected situations and crashes. An unhandled rejection can be intercepted by adding a listener to `"unhandledrejection"` event.[^1] + +Using this rules allows you to get warned _when a Promise doesn't seem to be handled_. Hence, the opposite is valid: when this rule is active, Promise statements are silenced when _they look like to be handled_. +Using the ways listed above, you are going to tell the rule that you likely have handled a possible rejection and hence silence it. + +Worth of mention is the [`void` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void), which doesn't handle its rejection but just makes the outcome to be ignored. Refer to [`ignoreVoid` option](#ignorevoid) for more details. + +More infos about Promise rejection handling can be found on MDN's page [_Using Promises (error handling)_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling). + +:::note +The rule of thumb here is: this rule should be intended as a way of putting reasonable guardrails, instead of blindly trust it into handling all your cases. +::: + +[^1]: Differences between platforms apply, on both where the listener is registered and event name. Refer to [`"unhandledrejection"` on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) for the web and [`"unhandledRejection"`](https://nodejs.org/api/process.html#event-unhandledrejection) for Node.JS. + ## Options ### `checkThenables` @@ -140,9 +160,7 @@ Voiding a Promise doesn't handle it or change the runtime behavior. The outcome // eslint-disable-next-line @typescript-eslint/no-floating-promises ``` -Such Promise rejection will still lead to an [`unhandledrejection` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) -being fired and error logs being printed. Refer to MDN's [_Using Promises (error handling)_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling) -to learn how to handle correctly a promise. +Such Promise rejection will still be unhandled, as explained in the above section [_Handling Promises Rejections_](#handling-promises-rejections). ::: Examples of **correct** code for this rule with `{ ignoreVoid: true }`: From 6e1d755cf40e0184d26706dbbba67d41f0bb7595 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 17 Sep 2024 18:30:23 +0200 Subject: [PATCH 08/14] Moved handling Promises paragraph up --- .../docs/rules/no-floating-promises.mdx | 38 +++++++++---------- 1 file changed, 18 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 658905503d56..b043eb0b3728 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -27,13 +27,29 @@ This rule also reports when an Array containing Promises is created and not prop - `Promise.any()` - `Promise.race()` -Refer to [Handling Promises Rejections](#handling-promises-rejections) below for more information about this rule. - :::tip `no-floating-promises` only detects unhandled Promise _statements_. See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements. ::: +## Handling Promises rejections + +Javascript doesn't know the concept of a function that cannot throw as well as of a Promise that cannot be rejected. +Attempting to handling a Promise rejection in important to attempt preventing unexpected situations and crashes. An unhandled rejection can be intercepted by adding a listener to `"unhandledrejection"` event.[^1] + +Using this rules allows you to get warned _when a Promise doesn't seem to be handled_. Hence, the opposite is valid: when this rule is active, Promise statements are silenced when _they look like to be handled_. +Using the ways listed above, you are going to tell the rule that you likely have handled a possible rejection and hence silence it. + +Worth of mention is the [`void` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void), which doesn't handle its rejection but just makes the outcome to be ignored. Refer to [`ignoreVoid` option](#ignorevoid) for more details. + +More infos about Promise rejection handling can be found on MDN's page [_Using Promises (error handling)_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling). + +:::note +The rule of thumb here is: this rule should be intended as a way of putting reasonable guardrails, instead of blindly trust it into handling all your cases. +::: + +[^1]: Differences between platforms apply, on both where the listener is registered and event name. Refer to [`"unhandledrejection"` on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) for the web and [`"unhandledRejection"`](https://nodejs.org/api/process.html#event-unhandledrejection) for Node.JS. + ## Examples @@ -83,24 +99,6 @@ await Promise.all([1, 2, 3].map(async x => x + 1)); -## Handling Promises rejections - -Javascript doesn't know the concept of a function that cannot throw as well as of a Promise that cannot be rejected. -Attempting to handling a Promise rejection in important to attempt preventing unexpected situations and crashes. An unhandled rejection can be intercepted by adding a listener to `"unhandledrejection"` event.[^1] - -Using this rules allows you to get warned _when a Promise doesn't seem to be handled_. Hence, the opposite is valid: when this rule is active, Promise statements are silenced when _they look like to be handled_. -Using the ways listed above, you are going to tell the rule that you likely have handled a possible rejection and hence silence it. - -Worth of mention is the [`void` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void), which doesn't handle its rejection but just makes the outcome to be ignored. Refer to [`ignoreVoid` option](#ignorevoid) for more details. - -More infos about Promise rejection handling can be found on MDN's page [_Using Promises (error handling)_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling). - -:::note -The rule of thumb here is: this rule should be intended as a way of putting reasonable guardrails, instead of blindly trust it into handling all your cases. -::: - -[^1]: Differences between platforms apply, on both where the listener is registered and event name. Refer to [`"unhandledrejection"` on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) for the web and [`"unhandledRejection"`](https://nodejs.org/api/process.html#event-unhandledrejection) for Node.JS. - ## Options ### `checkThenables` From 59cbb55d5d8047df1d5d70591c408431505c2c85 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 17 Sep 2024 18:31:49 +0200 Subject: [PATCH 09/14] Reworked a bit Handling Promises rejections --- packages/eslint-plugin/docs/rules/no-floating-promises.mdx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index b043eb0b3728..41c2eec7b133 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -35,9 +35,8 @@ See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that p ## Handling Promises rejections Javascript doesn't know the concept of a function that cannot throw as well as of a Promise that cannot be rejected. -Attempting to handling a Promise rejection in important to attempt preventing unexpected situations and crashes. An unhandled rejection can be intercepted by adding a listener to `"unhandledrejection"` event.[^1] -Using this rules allows you to get warned _when a Promise doesn't seem to be handled_. Hence, the opposite is valid: when this rule is active, Promise statements are silenced when _they look like to be handled_. +Using this rules allows you to get warned when a Promise doesn't _seem_ to be handled. Hence, the opposite is valid: when this rule is active, Promise statements are silenced when _they look like_ to be handled. Using the ways listed above, you are going to tell the rule that you likely have handled a possible rejection and hence silence it. Worth of mention is the [`void` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void), which doesn't handle its rejection but just makes the outcome to be ignored. Refer to [`ignoreVoid` option](#ignorevoid) for more details. @@ -48,8 +47,6 @@ More infos about Promise rejection handling can be found on MDN's page [_Using P The rule of thumb here is: this rule should be intended as a way of putting reasonable guardrails, instead of blindly trust it into handling all your cases. ::: -[^1]: Differences between platforms apply, on both where the listener is registered and event name. Refer to [`"unhandledrejection"` on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) for the web and [`"unhandledRejection"`](https://nodejs.org/api/process.html#event-unhandledrejection) for Node.JS. - ## Examples From b9851414438601d6412d94db791231af40669e74 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 17 Sep 2024 22:45:59 +0200 Subject: [PATCH 10/14] Removed Handling Promises rejection --- .../docs/rules/no-floating-promises.mdx | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 41c2eec7b133..237576817f98 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -32,21 +32,6 @@ This rule also reports when an Array containing Promises is created and not prop See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements. ::: -## Handling Promises rejections - -Javascript doesn't know the concept of a function that cannot throw as well as of a Promise that cannot be rejected. - -Using this rules allows you to get warned when a Promise doesn't _seem_ to be handled. Hence, the opposite is valid: when this rule is active, Promise statements are silenced when _they look like_ to be handled. -Using the ways listed above, you are going to tell the rule that you likely have handled a possible rejection and hence silence it. - -Worth of mention is the [`void` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void), which doesn't handle its rejection but just makes the outcome to be ignored. Refer to [`ignoreVoid` option](#ignorevoid) for more details. - -More infos about Promise rejection handling can be found on MDN's page [_Using Promises (error handling)_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling). - -:::note -The rule of thumb here is: this rule should be intended as a way of putting reasonable guardrails, instead of blindly trust it into handling all your cases. -::: - ## Examples From 5a96121deb3b1dddd710dea9c324937323260214 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 17 Sep 2024 22:51:10 +0200 Subject: [PATCH 11/14] Added link to mdn in the tip --- packages/eslint-plugin/docs/rules/no-floating-promises.mdx | 4 +++- 1 file changed, 3 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 237576817f98..64674715385c 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -28,8 +28,10 @@ This rule also reports when an Array containing Promises is created and not prop - `Promise.race()` :::tip -`no-floating-promises` only detects unhandled Promise _statements_. +`no-floating-promises` only detects apparently unhandled Promise _statements_. See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements. + +See [_Using promises (error handling) on MDN_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling) for a detailed writeup on promise error-handling. ::: ## Examples From 526258e0ca29c0c040a671c781eff355548bfbaa Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Thu, 19 Sep 2024 11:22:14 +0200 Subject: [PATCH 12/14] Removed ref to handling promises rejection (not existing anymore) --- packages/eslint-plugin/docs/rules/no-floating-promises.mdx | 2 +- 1 file changed, 1 insertion(+), 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 64674715385c..3ec556844f56 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -142,7 +142,7 @@ Voiding a Promise doesn't handle it or change the runtime behavior. The outcome // eslint-disable-next-line @typescript-eslint/no-floating-promises ``` -Such Promise rejection will still be unhandled, as explained in the above section [_Handling Promises Rejections_](#handling-promises-rejections). +Such Promise rejections will still be unhandled. ::: Examples of **correct** code for this rule with `{ ignoreVoid: true }`: From bf8343d62b0b84bc4242d2ff936414c20a131277 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Thu, 19 Sep 2024 19:25:36 +0200 Subject: [PATCH 13/14] Changed monospace comment in warning to link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Josh Goldberg ✨ --- .../eslint-plugin/docs/rules/no-floating-promises.mdx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx index 3ec556844f56..a880cdcc4f58 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -136,12 +136,8 @@ This option, which is `true` by default, allows you to stop the rule reporting p This can be a good way to explicitly mark a promise as intentionally not awaited. :::warning -Voiding a Promise doesn't handle it or change the runtime behavior. The outcome is just ignored, like disabling the rule with a - -``` -// eslint-disable-next-line @typescript-eslint/no-floating-promises -``` - +Voiding a Promise doesn't handle it or change the runtime behavior. +The outcome is just ignored, like disabling the rule with an [ESLint disable comment](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1). Such Promise rejections will still be unhandled. ::: From 44038ea2f924ec7db31ffe358fa4ece547177a7a Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Thu, 19 Sep 2024 19:25:59 +0200 Subject: [PATCH 14/14] Typo fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Josh Goldberg ✨ --- packages/eslint-plugin/docs/rules/no-floating-promises.mdx | 2 +- 1 file changed, 1 insertion(+), 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 a880cdcc4f58..355fe6aeb141 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.mdx @@ -31,7 +31,7 @@ This rule also reports when an Array containing Promises is created and not prop `no-floating-promises` only detects apparently unhandled Promise _statements_. See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements. -See [_Using promises (error handling) on MDN_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling) for a detailed writeup on promise error-handling. +See [_Using promises (error handling) on MDN_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#error_handling) for a detailed writeup on Promise error-handling. ::: ## Examples