Skip to main content
This rule disallows returning a value from the onSuccess function. Gadget silently ignores return values from onSuccess, so returning a value has no effect and may mislead developers about the function’s behavior.

Rule Details

This rule checks for return statements with values inside onSuccess exports and suggests removing the value or the entire return statement. Severity: Warning Auto-fixable: Yes

Examples

Incorrect

Correct

Auto-fixes

The rule automatically fixes return statements:
  • If the return is the last statement in the block, it removes the entire statement
  • Otherwise, it replaces the return value with a bare return;
Returning a value from onSuccess has no effect. Gadget silently discards the value. Use the run function if you need to return data to the client.

When to Use

This rule is included in the recommended config. It prevents confusion by making it clear that onSuccess return values are ignored.