| Summary: | Variable re-declarations not flagged in named FunctionExpression | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Mark Macdonald <mamacdon> |
| Component: | JS Tools | Assignee: | Michael Rennie <Michael_Rennie> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | Michael_Rennie |
| Version: | 9.0 | ||
| Target Milestone: | 10.0 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
Looks like the code in our rule is bogus:
if(node.type === "FunctionExpression" && node.id && node.id.name) {
scope = scope.upper;
}
if I take that code out it works as expected.
I don't recall why we have this check in there, it looks like a hack to workaround an old bug in escope (maybe?), but with the version we are using now, the scopes returned from context.getScope() all seem fine.
(In reply to Michael Rennie from comment #1) > I don't recall why we have this check in there, it looks like a hack to > workaround an old bug in escope (maybe?), but with the version we are using > now, the scopes returned from context.getScope() all seem fine. I don't remember either. It is probably an old workaround that can just be removed. |
Create a .js file containing this code: /*eslint no-unused-vars:0*/ (function fizz() { var a, a; }); var _ = function fizz2() { var a, a; }; (function fizz3() { var a, a; }()); Expected result: The re-declaration of 'a' inside each function should be flagged. Actual result: No warnings are shown Strangely, this behavior hinges on the FunctionExpressions being named: if you delete the names, you get the expected 3 warnings.