unnecessaryBinds
Reports unnecessary
.bind()calls.
✅ This rule is included in the ts logical presets.
Using .bind() on a function that doesn’t use this is unnecessary.
Additionally, using .bind() on arrow functions has no effect since arrow functions have lexical this binding.
Examples
Section titled “Examples”Functions Without this
Section titled “Functions Without this”const handler = function () { console.log("hello");}.bind(this);const handler = function () { console.log("hello");};Arrow Functions
Section titled “Arrow Functions”const callback = (() => { this.process();}).bind(context);const callback = () => { this.process();};Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you use .bind() with additional arguments to create partially applied functions,
this rule should not flag those cases.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
no-extra-bind - Oxlint:
eslint/no-extra-bind
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.