Skip to content

Require Async Suffix

Error
small-rules/require-async-suffix

Require async function names to end with Async.

Rationale

An async function returns a promise, and nothing at the call site shows that unless the name does. With the suffix, loadProfileAsync() without an await in front of it stands out on its own, and you don’t have to hover the function to find out.

It backs off where you don’t get to pick the name: methods marked override, and methods on an object whose shape comes from elsewhere. That covers objects passed straight into a call or new, checked with satisfies, or annotated with an imported type. Anything else you need to keep, put in except.

Diagnostic Messages

missingAsyncSuffix
Async functions must have names that end with Async.

Configuration

This rule accepts one options object after the severity.

exceptOptional

No description available.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/require-async-suffix": [
"error",
{
"except": [
"value"
]
}
]
}
}

Examples

Missing Async suffix
async function getAll(): Promise<string> {
return "value";
}
Async function suffix
async function getAllAsync(): Promise<string> {
return "value";
}