What it does
Flags functions declared with the `async` keyword that never use `await` in their body — including arrow functions and function expressions.
Why AI tools generate this pattern
The `async` keyword changes a function's return type to `Promise<T>`. If an `async` function never uses `await`, it's wrapping a synchronous result in a promise unnecessarily. This creates misleading function signatures, forces all callers to `await` a call that doesn't actually do async work, and adds slight overhead. AI tools add `async` defensively — "it might need to be async later" or because the pattern they copied was async. The result is functions that look async but aren't.
Code Examples
// async but never awaits — synchronous function masquerading as async
async function getUserName(user: User): Promise<string> {
return user.firstName + ' ' + user.lastName; // ← no await, no async needed
}
// Causes callers to unnecessarily await a sync operation
const name = await getUserName(user); // ← await is pointless here// Remove async — it's a synchronous function
function getUserName(user: User): string {
return user.firstName + ' ' + user.lastName;
}
const name = getUserName(user); // ← no await neededSafe Autofix
This rule supports a safe autofix for simple function bodies by inserting an explicit `await`.
Before fix:
const run = async () => doWork();After fix:
const run = async () => await (doWork());How to Fix
- Remove the `async` keyword. If the function is expected to become async in the future, that's fine — add `async` when you add the first `await`.
Nuances & False Positive Prevention
Legitimate usage can be exempted with inline disable comments (// ai-guard-disable-next-line no-async-without-await) when appropriate.
Configuration
Enable or override this rule in your ESLint configuration:
// eslint.config.mjs
export default [
{
plugins: { 'ai-guard': aiGuard },
rules: {
'ai-guard/no-async-without-await': 'warn',
},
},
];