Skip to content

recursionOnlyArguments

Reports function parameters that are only used in recursive calls.

✅ This rule is included in the ts logical and logicalStrict 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
function process(data: any, unusedParam: any): void
process
(
data: any
data
,
unusedParam: any
unusedParam
) {
if (
data: any
data
.
any
length
=== 0) {
return;
}
function process(data: any, unusedParam: any): void
process
(
data: any
data
.
any
slice
(1),
unusedParam: any
unusedParam
);
}
function
function traverse(node: any, depth: any): void
traverse
(
node: any
node
,
depth: any
depth
) {
if (!
node: any
node
) {
return;
}
function traverse(node: any, depth: any): void
traverse
(
node: any
node
.
any
left
,
depth: any
depth
);
function traverse(node: any, depth: any): void
traverse
(
node: any
node
.
any
right
,
depth: any
depth
);
}
const
const recurse: (value: any) => never
recurse
= (
value: any
value
) => {
return
const recurse: (value: any) => never
recurse
(
value: any
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 ❤️‍🔥 around the world by the Flint team and contributors.