functionCurryingRedundancy
Reports using
.apply()or.call()or when the context (thisvalue) 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.
Examples
Section titled “Examples”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]);function add(a: number, b: number) { return a + b;}const result = add(1, 2);const callback = (message: string) => message.toUpperCase();callback("hello");// Using .call() with a meaningful contextconst obj = { value: 10 };function getValue() { return this.value;}const contextResult = getValue.call(obj);// Using .apply() to pass an array of arguments with contextfunction greet(this: { name: string }, greeting: string) { return `${greeting}, ${this.name}!`;}const person = { name: "Alice" };greet.apply(person, ["Hello"]);Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
no-useless-call - Oxlint:
eslint/no-useless-call
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.