JSLint has some interesting messages, such as eval is evil.
when you use an eval
statement, and Weird relation.
when comparing two literals, e.g. 1 == 2
.
I was looking through a list of the JSLint messages, and noticed this one at the bottom of the list:
What the hell is this?
I looked through the JSLint source and found this code:
if (stack.length === 0) {
error("What the hell is this?", nexttoken);
}
I have been trying for a while, unsuccessfully, to write code that triggers this. Nothing I have read about JSLint talks about this error message, why it exists, or what causes it. I've briefly inspected the code, but I can't really understand what the stack is, how it is populated or what could cause it to be empty.
Can somebody write a code sample that will cause JSLint to scream What the hell is this?
or explain what prevents this from happening?
JSLint has some interesting messages, such as eval is evil.
when you use an eval
statement, and Weird relation.
when comparing two literals, e.g. 1 == 2
.
I was looking through a list of the JSLint messages, and noticed this one at the bottom of the list:
What the hell is this?
I looked through the JSLint source and found this code:
if (stack.length === 0) {
error("What the hell is this?", nexttoken);
}
I have been trying for a while, unsuccessfully, to write code that triggers this. Nothing I have read about JSLint talks about this error message, why it exists, or what causes it. I've briefly inspected the code, but I can't really understand what the stack is, how it is populated or what could cause it to be empty.
Can somebody write a code sample that will cause JSLint to scream What the hell is this?
or explain what prevents this from happening?
- 1 I don't have such code... but examining the snippet you posted I suspect that JSLint uses an internal stack with some (predefined?) size and only displays this message when that stack is empty where it shouldn't (checking XML)... this message only occurs if somewhere along the way a JSLint bug leads to an empty stack while the rest of the function believes there is a nested token to handle... – Yahia Commented Oct 11, 2011 at 17:29
- 3 Maybe it is an error which should/can never occur... just a thought. – Felix Kling Commented Oct 11, 2011 at 17:30
- I'd say there's a decent chance that it was written for internal use when developing the tool. If it encountered some condition it wasn't expecting, it output that message and the developer would investigate further. Just a guess. – riwalk Commented Oct 11, 2011 at 17:33
- 6 Holy crap. How can someone who writes code like that tell me how to write good code? :( – user166390 Commented Oct 11, 2011 at 17:39
- 2 @pst jshint.com ;) – Alex Turpin Commented Oct 11, 2011 at 17:43
2 Answers
Reset to default 16It looks a lot like a "can't happen" check (a form of defensive programming). If so, there might not be any way to trigger it in practice.
Looks like the error message is no longer there in the message list or source code.