This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 438319 - [eslint] implement no-shadow and fix no-redeclare
Summary: [eslint] implement no-shadow and fix no-redeclare
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: JS Tools (show other bugs)
Version: 6.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Mark Macdonald CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-26 16:47 EDT by Mark Macdonald CLA
Modified: 2014-11-27 17:16 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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