| Summary: | [eslint] Unreachable code warning should mark all statements as one problem | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Michael Rennie <Michael_Rennie> | ||||
| Component: | JS Tools | Assignee: | Michael Rennie <Michael_Rennie> | ||||
| Status: | RESOLVED WONTFIX | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | 8.0 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
I hit a similar problem, except only the last statement was indicated as a warning. There was only a quick fix available for removing the last line. See screenshot. Created attachment 250329 [details]
Screen shot
(In reply to John Arthorne from comment #1) > I hit a similar problem, except only the last statement was indicated as a > warning. There was only a quick fix available for removing the last line. > See screenshot. That is correctly marked. Any function or var declarations after a returnable statement are 'hoisted' to the start of the enclosing functional scope (so they are in fact not unreachable). For some more info on hoisting: http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html The more I think about this one, the more it kind of makes sense to mark each expression by itself, rather than try to make one big annotation - the advantages are that we can find specifically the offending expressions rather than trying to parse out / find nodes from a huge annotation. Closing wontfix |
Consider the following snippet: var foo = 10; switch(foo) { case 1: { throw e; f = 10; break; } } When linted you will see two warnings for unreachable code: 'f=10;' and 'break;'. both of these statements should be marked as one problem since all of it is unreachable. This would also simplify fixing the problem - rather than having to apply N fixes for N unreachable statements, there would be one fix for N statements.