Skip to content

functionCurryingRedundancy

Reports using .apply() or .call() or when the context (this value) provides no benefit.

✅ This rule is included in the ts logical preset.

Using .apply() .call() or with null or undefined as the context (first argument) provides no benefit over calling the function directly. Doing so adds unnecessary complexity and reduces code readability.

function add(a: number, b: number) {
return a + b;
}
const result = add.call(undefined, 1, 2);
function multiply(x: number, y: number) {
return x * y;
}
const value = multiply.call(null, 5, 3);
const callback = (message: string) => message.toUpperCase();
callback.apply(undefined, ["hello"]);
const compute = (a: number, b: number) => a + b;
compute.apply(null, [10, 20]);

This rule is not configurable.

If you have a specific coding pattern that requires explicit use of .apply() .call() or for consistency across a large codebase, even when the context is null or undefined, you might choose to disable this rule. However, in most cases, direct function calls improve code clarity and maintainability.

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