sindresorhus/eslint-plugin-unicorn

`no-fn-reference-in-iterator` false positives on non-array methods

Closed

#568 opened on Feb 27, 2020

 (24 comments) (1 reaction) (0 assignees)JavaScript (468 forks)user submission
bughelp wantedtypes

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

const obj = {filter: () => {}};
obj.filter([].join()); // error: Do not pass a function reference directly to an iterator method

.filter is not an iterator here. I think the rule confuses it with Array.prototype.filter and the false-positive seems specifically triggered by a CallExpression argument.

The autofix produces broken code for this case.

Contributor guide