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 and logicalStrict presets.

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
function add(a: number, b: number): number
add
(
a: number
a
: number,
b: number
b
: number) {
return
a: number
a
+
b: number
b
;
}
const
const result: number
result
=
function add(a: number, b: number): number
add
.
CallableFunction.call<undefined, [number, number], number>(this: (this: undefined, args_0: number, args_1: number) => number, thisArg: undefined, args_0: number, args_1: number): number

Calls the function with the specified object as the this value and the specified rest arguments as the arguments.

@paramthisArg The object to be used as the this object.

@paramargs Argument values to be passed to the function.

call
(
var undefined
undefined
, 1, 2);
function
function multiply(x: number, y: number): number
multiply
(
x: number
x
: number,
y: number
y
: number) {
return
x: number
x
*
y: number
y
;
}
const
const value: number
value
=
function multiply(x: number, y: number): number
multiply
.
CallableFunction.call<null, [number, number], number>(this: (this: null, args_0: number, args_1: number) => number, thisArg: null, args_0: number, args_1: number): number

Calls the function with the specified object as the this value and the specified rest arguments as the arguments.

@paramthisArg The object to be used as the this object.

@paramargs Argument values to be passed to the function.

call
(null, 5, 3);
const
const callback: (message: string) => string
callback
= (
message: string
message
: string) =>
message: string
message
.
String.toUpperCase(): string

Converts all the alphabetic characters in a string to uppercase.

toUpperCase
();
const callback: (message: string) => string
callback
.
CallableFunction.apply<undefined, [message: string], string>(this: (this: undefined, message: string) => string, thisArg: undefined, args: [message: string]): string (+1 overload)

Calls the function with the specified object as the this value and the elements of specified array as the arguments.

@paramthisArg The object to be used as the this object.

@paramargs An array of argument values to be passed to the function.

apply
(
var undefined
undefined
, ["hello"]);
const
const compute: (a: number, b: number) => number
compute
= (
a: number
a
: number,
b: number
b
: number) =>
a: number
a
+
b: number
b
;
const compute: (a: number, b: number) => number
compute
.
CallableFunction.apply<null, [a: number, b: number], number>(this: (this: null, a: number, b: number) => number, thisArg: null, args: [a: number, b: number]): number (+1 overload)

Calls the function with the specified object as the this value and the elements of specified array as the arguments.

@paramthisArg The object to be used as the this object.

@paramargs An array of argument values to be passed to the function.

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 ❤️‍🔥 around the world by the Flint team and contributors.