Skip to content

Commit 6420fa9

Browse files
committed
Ensure binding the this to member methods is not an unnecessary this
1 parent 5872ec9 commit 6420fa9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ const onlyEs = array.filter(function(char) {
108108
array.forEach(function(char) {
109109
this.log(char);
110110
}, console);
111+
112+
array.filter(this.isGood, this);
111113
```
112114

113115
## `array-func/recommended` Configuration

test/rules/no-unnecessary-this-arg.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ ruleTester.run('no-unnecessary-this-arg', rule, {
1414
'array.some((t) => t !== "a")',
1515
'Array.from(iterable, (t) => t.id)',
1616
'array.map(function(t) { return t.id; }, b)',
17-
'Array.from(iterable, function(t) { return t.id; }, b)'
17+
'Array.from(iterable, function(t) { return t.id; }, b)',
18+
'array.filter(this.isGood, this)'
1819
],
1920
invalid: [
2021
{

0 commit comments

Comments
 (0)