Skip to content

VBC-201: redundant-async ​

warning

Category: clean-code
Analysis: AST
File types: .ts, .tsx, .js, .jsx
Excluded paths: **/test/**, **/tests/**, **/__tests__/**, **/__mocks__/**, **/fixtures/**, **/e2e/**, **/*.test.*, **/*.spec.*
Tags: clean-code performance

What it reports ​

async function with no await at line {line}. The async keyword only wraps the return value in a Promise here; drop it or await something.

Flagged ​

ts
async function load() {
  return cached;
}
ts
async function load(pending: Promise<Item>) {
  return pending;
}

Not flagged ​

ts
async function load() {
  return await fetchIt();
}
ts
async function load(): Promise<Item[]> {
  return cached;
}
ts
class Provider {
  async getChildren(element?: Node): Promise<Node[]> {
    return [];
  }
}
ts
const parse = async (text: string): Promise<number> => Number(text);
ts
const props = { onToggle: async () => ({ enabled: true }) };
ts
function load() {
  return cached;
}
ts
const spy = vi.fn(async (name) => undefined);

AST check ​

  • Type: async-without-await

Released under the MIT License.