パッケージの詳細

@kapouer/eslint-plugin-no-return-in-loop

kapouer19.9kMIT1.0.0

eslint plugin to report return statements in loop

eslint, plugin

readme

eslint-plugin-no-return-in-loop

This plugin reports an error when there is an empty return in a loop:

Not okay:

for (const n of [1, 2, 3]) {
 if (n === 2) return; /* this was surely meant to be `break` or `continue`
}

Okay:

for (const n of [1, 2, 3]) {
 if (n === 2) return true;
}

Install:

npm install @kapouer/eslint-plugin-no-return-in-loop

Configure:

"plugins": [
 "@babel",
 "@kapouer/no-return-in-loop"
],
"rules": {
 "@kapouer/no-return-in-loop/no-return-in-loop": "error"
}