Skip to content

recursionOnlyArguments

Reports function parameters that are only used in recursive calls.

✅ This rule is included in the ts logical presets.

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.

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

This rule is not configurable.

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.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.