In Lodash version 3, it was possible to pass an additional parameter to methods that require binding, thisArg
.
However, in Lodash 4, this option was removed in favor of regular binding, and still using the old method could cause unexpected results.
This rule takes no arguments. However, it is affected by the lodash version
defined in the config's shared settings for Lodash.
In version 4, the following patterns are considered warnings:
var r = _.filter(users, function (user) {
return user.age > this.age;
}, this);
var r = _.reduce(numbers, multiply, 1, this);
The following patterns are not considered warnings:
var r = _.filter(users, function (user) {
return user.age > this.age;
}.bind(this));
In version 3, the following patterns are considered warnings:
var r = _.filter(users, function (user) {
return user.age > this.age;
}, this);
The following patterns are not considered warnings:
var r = _.filter(users, function (user) {
return user.age > this.age;
}.bind(this));