sindresorhus/eslint-plugin-unicorn

Use singular array element variable name for `no-fn-reference-in-iterator` rule if possible

クローズ

#754 opened on 2020/05/28

 (0 件のコメント) (1 件のリアクション) (0 人の担当者)JavaScript (468 件のフォーク)user submission
enhancementhelp wanted

Repository metrics

Stars
 (5,022 個のスター)
PR merge metrics
 (平均マージ 1d 16h) (30d で 399 merged PRs)

説明

const foo = items.map(fn);

We are suggesting

const foo = items.map((element) => fn(element));
const foo = items.map((element, index) => fn(element, index));
const foo = items.map((element, index, array) => fn(element, index, array));

We can use better variable name

const foo = items.map((item) => fn(item));
const foo = items.map((item, index) => fn(item, index));
const foo = items.map((item, index, items) => fn(item, index, items));
//                                  ^^^^^ this is not related, but we can use this name

コントリビューターガイド