Skip to content

Instantly share code, notes, and snippets.

@munro
Created July 12, 2012 20:05
Show Gist options
  • Save munro/3100600 to your computer and use it in GitHub Desktop.
Save munro/3100600 to your computer and use it in GitHub Desktop.
JSHint is bad
/*jshint undef: false */
var hello = 123,
world = 3421;
foo = 321,
bar = 421;
// passes!
var hello = 123,
world = 3421,
foo = 321,
bar = 421;
var hello = 123,
world = 3421;
window.foo = 321,
window.bar = 421;
/*jslint undef: true */
var hello = 123,
world = 3421;
foo = 421;
/**
* Fails:
* Expected 'foo' at column 1, not column 5.
* foo = 421;
*/
@munro
Copy link
Author

munro commented Jul 12, 2012

Woo, I broke it for real this time! I couldn't remember the exact syntax I encountered in the wild.

@valueof
Copy link

valueof commented Jul 12, 2012

This result was expected.

@munro
Copy link
Author

munro commented Jul 12, 2012

To be fair undef: false is a terrible option, but that's why people use JSHint, they like their warm_and_fuzzy flags.

@valueof
Copy link

valueof commented Jul 13, 2012

I don't think you know what to be fair means. When JSHint was forked JSLint shared the exact same behavior (undef was false by default) and we don't like to break backwards compatibility.

@munro
Copy link
Author

munro commented Jul 13, 2012

Aw yea! I thought undef existed in JSLint, but I didn't find it after looking for a second. I have to manipulate the example a bit, because JSLint doesn't allow , in statements. But anyways, this is where JSLint is superior, because indentation leads to certain expectations. Though, expectations are subjective. ;)

@munro
Copy link
Author

munro commented Jul 13, 2012

I actually was typing "To be fair, JSLint has this option ...", but I couldn't find it after looking at their site for a second. But you found it! 'Cause somebody on the internet is wrong, dammit! Also, your comment about expectations leads to some interesting concepts on why I believe JSLint to be superior to JSHint and CoffeeScript when it comes to writing quality JavaScript code. I'll distill my thoughts in a blog post later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment