Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 438319

Summary: [eslint] implement no-shadow and fix no-redeclare
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: JS ToolsAssignee: Mark Macdonald <mamacdon>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie
Version: 6.0   
Target Milestone: 8.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2014-06-26 16:47:36 EDT
Orion's current "no-redeclare" rule does too much. It warns about redeclaration of variables in the same scope (which is OK):

> function f() {
>    var blah;
>    var blah;   // "'blah' is already defined"
> }

.. But it also warns about shadowing (which is supposed to be the job of the "no-shadow" rule):
> function blah() {}
> 
> function g() {
>     var blah;  // "'blah' is already defined"
> }

... But strangely, it only complains about shadowing when a function declaration is shadowed. If a variable shadows another variable, or a function declaration shadows a variable, there is no warning:

> var blah;
> 
> function f() {
> 	var blah;  // not flagged
> }

To stay closer to upstream ESLint:
 * no-redeclare should *only* check for redeclaration within a single scope
 * The shadowing checks should be moved into a new "no-shadow" rule
 * no-shadow should consider shadowed variables, not just functions


Upstream docs:
[1] http://eslint.org/docs/rules/no-redeclare.html
[2] eslint.org/docs/rules/no-redeclare.html
Comment 1 Mark Macdonald CLA 2014-06-26 16:48:26 EDT
[2] http://eslint.org/docs/rules/no-shadow.html