@typescript-eslint/eslint-plugin 8.3.1-alpha.8 → 8.3.1-alpha.9

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,43 @@ import TabItem from '@theme/TabItem';
12
12
  This rule extends the base [`eslint/require-await`](https://eslint.org/docs/rules/require-await) rule.
13
13
  It uses type information to allow promise-returning functions to be marked as `async` without containing an `await` expression.
14
14
 
15
+ :::note
16
+ `yield` expressions in [async generator functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*) behave differently from sync generator functions (they unwrap promises), so the base rule never checks async generator functions. On the other hand, our rule uses type information and can detect async generator functions that both never use `await` and always yield non-promise values.
17
+ :::
18
+
15
19
  ## Examples
16
20
 
17
- Examples of **correct** code for this rule:
21
+ <Tabs>
22
+ <TabItem value="❌ Incorrect">
23
+
24
+ ```ts
25
+ async function returnNumber() {
26
+ return 1;
27
+ }
28
+
29
+ async function* asyncGenerator() {
30
+ yield 1;
31
+ }
32
+
33
+ const num = returnNumber();
34
+ const callAsyncGenerator = () => asyncGenerator();
35
+ ```
36
+
37
+ </TabItem>
38
+ <TabItem value="✅ Correct">
18
39
 
19
40
  ```ts
20
- async function returnsPromise1() {
21
- return Promise.resolve(1);
41
+ function returnNumber() {
42
+ return 1;
22
43
  }
23
44
 
24
- const returnsPromise2 = () => returnsPromise1();
45
+ function* syncGenerator() {
46
+ yield 1;
47
+ }
48
+
49
+ const num = returnNumber();
50
+ const callSyncGenerator = () => syncGenerator();
25
51
  ```
52
+
53
+ </TabItem>
54
+ </Tabs>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.3.1-alpha.8",
3
+ "version": "8.3.1-alpha.9",
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.3.1-alpha.8",
64
- "@typescript-eslint/type-utils": "8.3.1-alpha.8",
65
- "@typescript-eslint/utils": "8.3.1-alpha.8",
66
- "@typescript-eslint/visitor-keys": "8.3.1-alpha.8",
63
+ "@typescript-eslint/scope-manager": "8.3.1-alpha.9",
64
+ "@typescript-eslint/type-utils": "8.3.1-alpha.9",
65
+ "@typescript-eslint/utils": "8.3.1-alpha.9",
66
+ "@typescript-eslint/visitor-keys": "8.3.1-alpha.9",
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.3.1-alpha.8",
78
- "@typescript-eslint/rule-tester": "8.3.1-alpha.8",
77
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.3.1-alpha.9",
78
+ "@typescript-eslint/rule-tester": "8.3.1-alpha.9",
79
79
  "ajv": "^6.12.6",
80
80
  "cross-env": "^7.0.3",
81
81
  "cross-fetch": "*",