4 ms·
JSHint, A JavaScript Code Quality Tool
- msarchet 15y agoWould be really nice if I didn't have to scroll down to see errors.
- joshuacc 15y agoIdeally, you won't be using the web interface, but running the command line utility version. My company recently implemented this as part of a git pre-commit hook so that we're less likely to have a silly syntax mistake cause problems.
- taylorbuley 15y agoIn an ideal world, I'd put every piece of JS I write first through jslint and then through jshint -- maybe even using git hooks
- johnweir 15y agoI have been using the jshint vim plugin http://www.vim.org/scripts/script.php?script_id=3576 http://www.vim.org/scripts/script.php?script_id=3576 https://github.com/walm/jshint.vim https://github.com/walm/jshint.vim This has really helped catch some dumb errors and even make some nice recommendations.
- bcrescimanno 15y agoYou might check out Syntastic. It supports JSHint if you have it installed and also supports other languages. I switched to it after using the JSHint plugin for a while. https://github.com/scrooloose/syntastic https://github.com/scrooloose/syntastic
- johnweir 15y agoVery nice. Thanks.
- bdg 15y agoI'm a bit of an evangelical when it comes to static code analysis like this. I insist your code should work to a spec-- not necessarily Crockford's JSLint spec, but a spec, which is why I really like JSHint. But I find I can't really convince anyone of it being useful, I remember being in an interview for a startup I read about on here and started talking about this as a tool I use (they asked "What tools do you use"). They basically brushed it off as "yeah, I don't think this is super useful, we probably have bigger problems than a missing semicolon". As I understand it, general perception of people seems to be it's a tool for finding missing semicolons. I don't know how to give this a decent elevator pitch so other people can see the light.
- mark_story 15y agoFunny they should say that. An extra comma can take down multiple versions of IE, and is something tools like JSHint can easily catch. I can't think of a good reason not to use JSHint to catch stupid mistakes we all make.
- bcrescimanno 15y agoJohn Carmack wrote a great blog post a while back about Static Code Analysis. http://altdevblogaday.com/2011/12/24/static-code-analysis/ http://altdevblogaday.com/2011/12/24/static-code-analysis/ While not all of this is immediately applicable to JSHint and the like, it provides some insight into why static code analysis can be seen as helpful. As you also mention, it's really helpful for code within a codebase to be consistently written. JSHint can help enforce some of that consistency. This is where JSHint really shines. If your JS is tied to some sort of "build" process (even a short 1-2 second one), catching errors before running the build is incredibly helpful. If you intend to minify your JS code (as you should) before distribution, finding missing semicolons can be very important, indeed. I find the most helpful JSHint errors to be about mistyped variable names. It's so much easier to see that in my editor, fix it, and THEN run it in the browser.
- simanyay 15y agoI used to have this problem, now I just wait until the missing semicolon costs someone a day of debugging or a broken deploy.
- jzting 15y agoTextMate bundle is quite nice as well: http://fgnass.posterous.com/jslint-in-textmate http://fgnass.posterous.com/jslint-in-textmate
- eric-hu 15y agoIf anyone has integrated this into a Coffeescript development cycle, I'd love to hear about how you've done it.