3 ms·
Since everyone is chiming in with ways to prevent this sort of thing, here is another: js2 mode for Emacs[1]. This is a mode originally written by Steve Yegge a
by tikhonj 15y ago
Since everyone is chiming in with ways to prevent this sort of thing, here is another: js2 mode for Emacs[1]. This is a mode originally written by Steve Yegge and then modified by some other people (be sure to get that version) that actually parses the code and, among other things, highlights global variables in a different color than local ones. I find this, along with the other things js2 does, helps prevent a whole host of annoying JavaScript issues, as I type.
[1]: https://github.com/mooz/js2-mode https://github.com/mooz/js2-mode
- nkassis 15y agoI was going to say the same thing, it also makes me avoid missing semicolons by making those errors feel like sores in my code. I can't let them mess things up they need to be gone before I can write another line.
- almost 15y agoHave you had any luck getting it to handle modern JavaScript style? Whenever I've tried js2-mode it really hasn't liked jQuery style nested anonymous functions.
- gcv 15y agoDo you have a specific example in mind? It works pretty well for me.
- tikhonj 15y agoTry using the version I linked rather than the original. It has a bunch of improvements including how it handles indenting functions. I've done some moderately complicated jQuery development with it, as well as some node.js stuff for fun, and have had no issues in either case.