Skip to content

No Recursive

Suggestion
small-rules/no-recursive

Disallow recursive function calls to prevent stack overflow.

Rationale

This lint will yell at you over recursion. I added this rule specifically because Luau does not support tail-call optimization (as confirmed by Roblox employees), meaning recursion will blow your stack. If that wasn’t enough, NASA’s Power of 10 rules for safety-critical code explicitly bans direct or indirect recursion to keep control flow deterministic and bounded. Good if you are writing code that prioritizes performance and safety.

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; }