sindresorhus/eslint-plugin-unicorn
Rule proposal: `no-break-in-nested-loop`
Chiusa
#1055 aperta il 23 gen 2021
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 4h 30m) (26 PR mergiate in 30 g)
Descrizione
Actually, getting this because of auto-fix for no-array-for-each rule, it fix return in nested .forEach to continue.
It's not clear what to break/continue, when loop is nested.
Fail
for (const foo of bar) {
for (const baz of foo) {
// ...
break;
}
}
for (const foo of bar) {
while(foo.pop()) {
// ...
continue;
}
}
A even confusing case
for (const foo of bar) {
switch (foo) {
case 1:
// ...
break;
case 2:
// ...
continue;
}
}
Pass
function processFoo() {
for (const baz of foo) {
// ...
break;
}
}
for (const foo of bar) {
processFoo(foo)
}