Skip to content

No Recursive

Suggestion
small-rules/no-recursive

Disallow recursive function calls to prevent stack overflow.

Rationale

This lint flags a call that calls itself. Luau has no tail calls. Roblox staff said so. That call can fill the stack. The Power of 10 rules also ban that kind of call, direct or not. Each path has a fixed bound. Use it when speed and safety come first.

Diagnostic Messages

noRecursive
Recursion is not allowed (JPL Power of 10). Use iteration instead — a loop or explicit stack.

Configuration

This rule accepts one options object after the severity.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-recursive": [
"error",
{}
]
}
}

Examples

Direct recursive function call
function factorial(n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
Simple non-recursive function
function foo() { return 1; }