useAwaitThenable
此内容尚不支持你的语言。
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/useAwaitThenable - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Inspired from
@typescript-eslint/use-await-thenable
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useAwaitThenable": "error" } } }}Description
Section titled “Description”Enforce that await is only used on Promise values.
Examples
Section titled “Examples”Invalid
Section titled “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://developer.mozilla.org/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://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#thenables
await Promise.resolve('value');
const createValue = async () => 'value';await createValue();Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.