recursionOnlyArguments
Reports function parameters that are only used in recursive calls.
✅ This rule is included in the tslogicalandlogicalStrictpresets.
Parameters that are only passed through to recursive calls without being used in the function body serve no functional purpose. This pattern often indicates a mistake where a parameter was intended to be used but is only being forwarded through recursive calls. Such parameters increase cognitive complexity, may impact performance, and suggest the function is only useful internally for iteration or recursion.
Examples
Section titled “Examples”function process(data, unusedParam) { if (data.length === 0) { return; } process(data.slice(1), unusedParam);}function traverse(node, depth) { if (!node) { return; } traverse(node.left, depth); traverse(node.right, depth);}const recurse = (value) => { return recurse(value);};function process(data) { if (data.length === 0) { return; } process(data.slice(1));}function traverse(node, depth) { if (!node) { return; } console.log(`Depth: ${depth}`); traverse(node.left, depth + 1); traverse(node.right, depth + 1);}function factorial(n) { if (n <= 1) { return 1; } return n * factorial(n - 1);}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”This rule might get in your way if you have functions where parameters are intentionally passed through for API consistency or future extensibility, even if they’re not currently used in the function body itself. Doing so is rare and typically indicates a design issue that should be addressed. You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Oxlint:
oxc/only-used-in-recursion