useAwaitThenable
¥Summary
-
规则生效日期:
v2.3.9¥Rule available since:
v2.3.9 -
诊断类别:
lint/nursery/useAwaitThenable¥Diagnostic Category:
lint/nursery/useAwaitThenable -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
-
灵感来自
@typescript-eslint/use-await-thenable¥Inspired from
@typescript-eslint/use-await-thenable
-
¥How to configure
{ "linter": { "rules": { "nursery": { "useAwaitThenable": "error" } } }}¥Description
强制要求 await 仅用于 Promise 值。
¥Enforce that await is only used on Promise values.
¥Examples
¥Invalid
await 'value';/invalid-primitive.js:1:1 lint/nursery/useAwaitThenable ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ `await` used on a non-Promise value.
> 1 │ await ‘value’;
│ ^^^^^^^^^^^^^
2 │
ℹ This may happen if you accidentally used `await` on a synchronous value.
ℹ Please ensure the value is not a custom “thenable” implementation before removing the `await`: https://web.nodejs.cn/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#thenables
const createValue = () => 'value';await createValue();/invalid-function-call.js:2:1 lint/nursery/useAwaitThenable ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ `await` used on a non-Promise value.
1 │ const createValue = () => ‘value’;
> 2 │ await createValue();
│ ^^^^^^^^^^^^^^^^^^^
3 │
ℹ This may happen if you accidentally used `await` on a synchronous value.
ℹ Please ensure the value is not a custom “thenable” implementation before removing the `await`: https://web.nodejs.cn/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#thenables
¥Valid
await Promise.resolve('value');
const createValue = async () => 'value';await createValue();¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号