no-extra-bind
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"no-extra-bind": "error",
},
},
];const x = function () {
foo();
}.bind(bar);
const y = (() => {
foo();
}).bind(bar);
const z = (() => {
this.foo();
}).bind(bar);
const a = function () {
(function () {
this.foo();
}());
}.bind(bar);
const b = function () {
function foo() {
this.bar();
}
}.bind(baz);// useless bind
const boundGetName = (function getName() {
return "ESLint";
}).bind({ name: "ESLint" });
console.log(boundGetName()); // "ESLint"const x = function () {
this.foo();
}.bind(bar);
const y = function (a) {
return a + 1;
}.bind(foo, bar);Examples from the ESLint documentation.
no-extra-bind
eslint
export default [
{
rules: {
"no-extra-bind": "error",
},
},
];no-extra-bind
eslint plugin · suspicious
{
"rules": {
"no-extra-bind": "error"
}
}nursery/noUselessBind
nursery · since 2.6.9
{
"linter": {
"rules": {
"nursery": {
"noUselessBind": "error"
}
}
}
}Disallow new operators with the Function object
Disallow new operators with the String, Number, and Boolean objects
Disallow throwing literals as exceptions
Disallow unnecessary computed property keys in objects and classes