EDIT: Syntastic is configured to use JSLint
EDIT2: I am using JavascriptLint, not JSLint
On the below code syntastic warns function inside does not always return a value
function(){
switch(age){
case 1:
return 'won';
case 2:
return 'too';
case 3:
return 'tree';
default:
throw 'wow man, you are old!';
break; //technically redundant
}
}
I realize default
does not return a value, but the throw
ends the execution. Is this a Syntastic error, or should I change my coding style? Should I put a return
statement after throw
?
Syntactic uses JSLint under the hood to check Javascript syntax.
JSLint is known to be overcautious in order to avoid errors. You can either ignore the message to your better judgement, or turn off this particular warning, or add a redundant return
there.
Personally I prefer to satisfy JSLint's requirements over turning off warnings. Just make sure to add a //Satisfying JSlint
comment near the return
so other people will understand the redundancy.