sindresorhus/eslint-plugin-unicorn

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

Chiusa

#568 aperta il 27 feb 2020

 (24 commenti) (1 reazione) (0 assegnatari)JavaScript (468 fork)user submission
bughelp wantedtypes

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

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.

Guida contributor