You may also consider using the "smarttabs" option available in JSHint (JSHint is a replacement for JSLint, only better).
This article is really insightful, objectively explains the trade-offs associated with gaps v (I did not understand that there was even so much that could be said on this issue), and demonstrates how the intelligent logic of tabs should behave:
http://www.emacswiki.org/emacs/SmartTabs
Basically, if you use tabs for "indentation", you are allowed to use spaces for "alignment", if any spaces "are used only for alignment", i.e. that they are preceded by the correct number of indent tabs:
What makes this piece of code legal ("---->" represents TAB):
function foo() { ---->var a = 4, ----> b = 5, ----> c = 6; }
You can do this with a file called .jshintrc:
{ "smarttabs": true }
Or you can install it in the source code with a comment:
/*jslint smarttabs:true */
Or you could just completely drop the tabs ... (a religious war sets in).
Personally, I use JSHint, which is a JSLint derivative project with possibly more configuration, etc. For most purposes, they are one and the same tool. http://jshint.com/docs/#options . I would recommend this. Most parameters are shared between two tools.
I also do not use tabs. Ever. Given the choice, I'm a guy with two spaces.
Dave Dopson Apr 19 '12 at 23:44 2012-04-19 23:44
source share