I am trying to detect nested loop with the same index which looks like this:
for(let i = 0; i < 10; i++) {
for(let i = 0; i < 10; i++) {
}
}
I have searched Eslint rules but haven't found any solution so far. Is there a way to detect this bad code smell? Thanks a lot.
ESLint has the
no-shadowrule that would flag that up, as well as other places where you've shadowed an outer scope variable with an inner scope one. For example:Demo on the ESLint site: