return await outside a try waits for a promise the async function would return anyway
What it finds
return await load(); outside any try: an async function returns a promise that follows the returned one in any case, so await there only adds a step. Inside a try block, or a catch with a finally, it is needed and left alone; return-skips-catch reports where it is missing.
The fix removes await. Stack traces of a rejection then no longer show this function, so it is offered as unsafe.
From the rule's source, redundant_return_await.rs.
async function load(id: string) { return await fetch(id);tx0 reports: this await is not needed}async function guarded(id: string) { try { return await fetch(id); } catch (e) { return null; }}async function cleaned(id: string) { try { return 1; } catch (e) { return await fetch(id); } finally { done(); }}function done() {} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:redundant-return-await" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:redundant-return-await] reason="..."tx0 explain tx0/ts:redundant-return-await shows the same in the terminal. Found a false positive? Report it.