4 ms·
> 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 lin
by almost 15y ago
> 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.
- apike 15y agoEven 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.
- almost 15y agoSounds 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 :)
- daleharvey 15y agoI wrote a jshint mode for emacs https://github.com/daleharvey/jshint-mode https://github.com/daleharvey/jshint-mode
- wahnfrieden 15y agoI use jshint in vim as well: https://github.com/wookiehangover/jshint.vim https://github.com/wookiehangover/jshint.vim
- eric-hu 15y agodoes this work for coffeescript as well?
- philjackson 15y agoUnless you use backticks, coffee will always pass jslint tests.
- vinnycoyne 15y agoNever heard of JSHint. Thanks for the tip!
- simanyay 15y agoIndeed, JSHint is designed to catch those kind of mistakes. Here is the offending code and its JSHint report: http://www.jshint.com/reports/57010 http://www.jshint.com/reports/57010