This message is documented quite concisely on the JSLint instructions page:
JSLintexpects that a return, break, continue, or throw statement will be followed by a } or case or default
At best, the presence unreachable code is indicative of general laziness on behalf of the developer, and, at worst, it may highlight a potential bug. Either way, JSLint is fully justified in raising the error.
The following code shows a scenario where this might arise:
function MyFunc(){
var x = 0;
return x;
x++;
}
JSLint is also savvy enough to look within conditional statements…
function MyFunc(){
var b = false;
if (b){
return 1;
}
else{
return 2;
}
return 3;
}
…loops…
function MyFunc(){
var x = 0;
var y = 0;
for (x=0; x<10; x++){
if (x<5){
break;
y++;
}
}
}
…and the not often seen “throw” statement.
function MyFunc(){
var x = 0;
throw "MyError";
x++;
}
This is just another way that JSLint can help you identify potential issues earlier in the development process.
A Guide To JSLint Messages
This article is one of a series on the error and warning messages produced by JSLint.
[...] [...]
function foo ()
{
bar();
return;
function bar() { stuff }
}
JSLint claims bar is unreachable. Not true. It will also claim that bar is used before it’s defined (true-ish). But the cure (var bar;) is worse than the perceived issue.