Skip to content
← Back to rules

eslint/no-extra-bind Suspicious

🚧 An auto-fix is planned for this rule, but not implemented at this time.

What it does ​

Disallow unnecessary calls to .bind().

Why is this bad? ​

This rule is aimed at avoiding the unnecessary use of bind() and as such will warn whenever an immediately-invoked function expression (IIFE) is using bind() and doesn’t have an appropriate this value. This rule won’t flag usage of bind() that includes function argument binding.

Examples ​

Examples of incorrect code for this rule:

js
const x = function () {
  foo();
}.bind(bar);

const z = (() => {
  this.foo();
}).bind(this);

Examples of correct code for this rule:

js
const x = function () {
  this.foo();
}.bind(bar);
const y = function (a) {
  return a + 1;
}.bind(foo, bar);

How to use ​

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "no-extra-bind": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "no-extra-bind": "error",
  },
});
bash
oxlint --deny no-extra-bind

Version ​

This rule was added in v1.1.0.

References ​