no-useless-recursion
UnreleasedConfiguration
Rule details
Disallows directly returning a call to the same named function. A loop can express simple tail recursion without growing the call stack.
The rule ignores optional calls, calls to shadowed names, and generator
functions. It also skips returns inside try, catch, or finally, or while a
resource declared with using or await using is still in scope.
Examples of incorrect code for this rule
Examples of correct code for this rule
Options
This rule has no options or automatic fixes.
Differences from upstream
Rslint skips calls to a function declaration's name when that name is reassigned in the same file. A saved reference can still call the original function after a later reassignment.
In scripts, writing a known property of globalThis can also replace a
top-level function with that name.
In non-strict scripts, a function declared in a block can make a different function available under the same name outside the block. Rslint skips calls that could use that function.
In scripts, Rslint skips a call when a with statement can supply the same name
from an object.