sindresorhus/eslint-plugin-unicorn

Rule proposal: `no-duplicate-loops`

Open

#846 创建于 2020年9月30日

在 GitHub 查看
 (24 评论) (7 反应) (0 负责人)JavaScript (5,022 star) (468 fork)user submission
help wantednew rule

描述

I've seen this a couple of times

Error

for (const gamma of bars.map(alpha => alpha.beta.gamma)) {
  gamma('ray')
}
 
for (const act of actions.filter(act => typeof act === 'function')) {
  act('a fool')
}

Pass

for (const alpha of bars) {
  alpha.beta.gamma('ray')
}


for (const act of actions) {
  if (typeof act === 'function') {
    act('a fool')
  }
}

贡献者指南