Skip to content

suspending-macro-argument

Reports await, yield, or import() inside an argument of style() or another macro.

This rule reports await, yield, or a dynamic import() inside an argument of style() or another macro. The compiler can move or skip argument expressions, so the code would not wait or load where you wrote it.

Reported

async function props() {
  return style({ "--x": await Promise.resolve(1) });suspending-macro-argument: evaluate await, yield, and dynamic imports outside macro arguments, then pass their values
}

Fixed

async function props() {
  const value = await Promise.resolve(1);
  return style({ "--x": value });
}

How to fix

Wait for the value before the call, store it in a variable, and pass the variable, as in the example.

Rule settings

PresetSeverity
recommendeddeny
strictdeny
stylisticoff

Configure lint to change the severity or options.