@typescript-eslint/eslint-plugin 8.6.1-alpha.6 → 8.6.1-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,14 +12,13 @@ import TabItem from '@theme/TabItem';
|
|
12
12
|
A "floating" Promise is one that is created without any code set up to handle any errors it might throw.
|
13
13
|
Floating Promises can cause several issues, such as improperly sequenced operations, ignored Promise rejections, and more.
|
14
14
|
|
15
|
-
This rule
|
16
|
-
Valid ways of handling a Promise-valued statement include:
|
15
|
+
This rule will report Promise-valued statements that are not treated in one of the following ways:
|
17
16
|
|
18
|
-
- `await`ing it
|
19
|
-
- `return`ing it
|
20
|
-
- `void`ing it
|
21
17
|
- Calling its `.then()` with two arguments
|
22
18
|
- Calling its `.catch()` with one argument
|
19
|
+
- `await`ing it
|
20
|
+
- `return`ing it
|
21
|
+
- [`void`ing it](#ignorevoid)
|
23
22
|
|
24
23
|
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:
|
25
24
|
|
@@ -29,8 +28,10 @@ This rule also reports when an Array containing Promises is created and not prop
|
|
29
28
|
- `Promise.race()`
|
30
29
|
|
31
30
|
:::tip
|
32
|
-
`no-floating-promises` only detects unhandled Promise _statements_.
|
31
|
+
`no-floating-promises` only detects apparently unhandled Promise _statements_.
|
33
32
|
See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements.
|
33
|
+
|
34
|
+
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.
|
34
35
|
:::
|
35
36
|
|
36
37
|
## Examples
|
@@ -134,6 +135,12 @@ await createMyThenable();
|
|
134
135
|
This option, which is `true` by default, allows you to stop the rule reporting promises consumed with the [`void` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void).
|
135
136
|
This can be a good way to explicitly mark a promise as intentionally not awaited.
|
136
137
|
|
138
|
+
:::warning
|
139
|
+
Voiding a Promise doesn't handle it or change the runtime behavior.
|
140
|
+
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).
|
141
|
+
Such Promise rejections will still be unhandled.
|
142
|
+
:::
|
143
|
+
|
137
144
|
Examples of **correct** code for this rule with `{ ignoreVoid: true }`:
|
138
145
|
|
139
146
|
```ts option='{ "ignoreVoid": true }' showPlaygroundButton
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.6.1-alpha.
|
3
|
+
"version": "8.6.1-alpha.7",
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -60,10 +60,10 @@
|
|
60
60
|
},
|
61
61
|
"dependencies": {
|
62
62
|
"@eslint-community/regexpp": "^4.10.0",
|
63
|
-
"@typescript-eslint/scope-manager": "8.6.1-alpha.
|
64
|
-
"@typescript-eslint/type-utils": "8.6.1-alpha.
|
65
|
-
"@typescript-eslint/utils": "8.6.1-alpha.
|
66
|
-
"@typescript-eslint/visitor-keys": "8.6.1-alpha.
|
63
|
+
"@typescript-eslint/scope-manager": "8.6.1-alpha.7",
|
64
|
+
"@typescript-eslint/type-utils": "8.6.1-alpha.7",
|
65
|
+
"@typescript-eslint/utils": "8.6.1-alpha.7",
|
66
|
+
"@typescript-eslint/visitor-keys": "8.6.1-alpha.7",
|
67
67
|
"graphemer": "^1.4.0",
|
68
68
|
"ignore": "^5.3.1",
|
69
69
|
"natural-compare": "^1.4.0",
|
@@ -74,8 +74,8 @@
|
|
74
74
|
"@types/marked": "^5.0.2",
|
75
75
|
"@types/mdast": "^4.0.3",
|
76
76
|
"@types/natural-compare": "*",
|
77
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.6.1-alpha.
|
78
|
-
"@typescript-eslint/rule-tester": "8.6.1-alpha.
|
77
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.6.1-alpha.7",
|
78
|
+
"@typescript-eslint/rule-tester": "8.6.1-alpha.7",
|
79
79
|
"ajv": "^6.12.6",
|
80
80
|
"cross-env": "^7.0.3",
|
81
81
|
"cross-fetch": "*",
|