no-useless-call
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-useless-call": "error",
},
},
];// These are same as `foo(1, 2, 3);`
foo.call(undefined, 1, 2, 3);
foo.apply(undefined, [1, 2, 3]);
foo.call(null, 1, 2, 3);
foo.apply(null, [1, 2, 3]);
// These are same as `obj.foo(1, 2, 3);`
obj.foo.call(obj, 1, 2, 3);
obj.foo.apply(obj, [1, 2, 3]);// The `this` binding is different.
foo.call(obj, 1, 2, 3);
foo.apply(obj, [1, 2, 3]);
obj.foo.call(null, 1, 2, 3);
obj.foo.apply(null, [1, 2, 3]);
obj.foo.call(otherObj, 1, 2, 3);
obj.foo.apply(otherObj, [1, 2, 3]);
// The argument list is variadic.
// Those are warned by the `prefer-spread` rule.
foo.apply(undefined, args);
foo.apply(null, args);
obj.foo.apply(obj, args);Examples from the ESLint documentation.
no-useless-call
eslint
export default [
{
rules: {
"no-useless-call": "error",
},
},
];no-useless-call
eslint plugin · perf
{
"rules": {
"no-useless-call": "error"
}
}nursery/noUselessCall
nursery · since 2.6.0
{
"linter": {
"rules": {
"nursery": {
"noUselessCall": "error"
}
}
}
}Disallow variable or function declarations in nested blocks
Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals
Disallow returning value from constructor
Require template literals instead of string concatenation
Disallow the use of Math.pow in favor of the ** operator
Enforce the use of the radix argument when using parseInt()