[go: up one dir, main page]

Proposal for new ESLint rule: no-shadow

In order to improve the robustness of the codebase, I propose adding the no-shadow ESLint rule (see here).

This rule is pretty straightforward and does not require a big effort. It can prevent silly bugs.

For instance, here we can see a funny-looking code:

if (objectId > objectId) {
    console.warn(`weird: pickingId (${objectId}) > visibleId (${objectId})`);
}

It was rewritten by commit 2dd0dc14 which renamed two variables to objectId (one in a larger scope than an other). Technically it builds but the code makes no sense because one variable is shadowed by another. With the no-shadow rule, this would not have been possible.

This is a follow-up of #618 (closed).