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')
  }
}

貢獻者指南