Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I would posit here that nothing I could do in best practice (manual front-end testing, unit testing, error handling, etc.) would have caught the offending line.

jshint would have caught it. You need to run jshint on your code or you will get silly errors like this. Simple.



Even better is setting your editor to run JSHint when you save a .js file, and let you know if there are problems. Not only does it avoid stupid bugs, it saves time round-tripping to the browser for trivial issues like syntax errors.


Sounds like a good idea. I know emacs flymake mode can be set up to underline problems detected by jshint. Personally I like to have the tests and jshint run by a hotkey so I can happily move the code through invalid states (towards a valid goal) without being constantly complained at :)


I wrote a jshint mode for emacs

https://github.com/daleharvey/jshint-mode



does this work for coffeescript as well?


Unless you use backticks, coffee will always pass jslint tests.


Never heard of JSHint. Thanks for the tip!


Indeed, JSHint is designed to catch those kind of mistakes. Here is the offending code and its JSHint report: http://www.jshint.com/reports/57010




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: