Asyncwarnstrict preset✓ autofix supported

ai-guard/no-async-without-await

Identifies async functions lacking await expressions, eliminating unnecessary promise wrappers

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

Incorrect (Flagged by AI Guard)
// 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
Correct (Safe & Deterministic)
// Remove async — it's a synchronous function
function getUserName(user: User): string {
  return user.firstName + ' ' + user.lastName;
}

const name = getUserName(user); // ← no await needed

Safe 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

  1. 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
// eslint.config.mjs
export default [
  {
    plugins: { 'ai-guard': aiGuard },
    rules: {
      'ai-guard/no-async-without-await': 'warn',
    },
  },
];

Related Rules