Reputation: 10781
I'm coming over from PHP where the convention is to use 4 space tabs. I've noticed that in a lot of examples (and project bootstrap code) 2 spaces is used. I haven't been able to find definitive style guides that mention spacing for these projects so I'm wondering if this is actually the convention.
Upvotes: 0
Views: 1471
Reputation: 113
Find the below urls this can be helpful if you are new to these: http://jade-lang.com/api/
http://learnboost.github.io/stylus/
http://expressjs.com/guide.html
Upvotes: 2
Reputation: 2408
Let me start by saying - according to the requirements of the language (Javascript) the 2 spaces are NOT REQUIRED (infact most of the times you can get away without using a ;
too at the end). However if you mean to ask whether people use it ? Then here is the answer :
For Node - it starts from here so the creator of Node (and also maintainer and BDFL) !! (Ryan-Dahl aka the "benevolent dictator") insisted on using the 2 spaces . Ofcourse he is the creator so everybody has a tendency to follow.
Tabs vs Spaces
Let's start with the religious problems first. Our benevolent dictator has chosen 2 space indention for the node core, so you would do well to follow his choice.
Then comes TJ Holowaychuk author of Express, Jade, Stylus, and Mocha quoted from here
has an extremely consistent style. TJ uses two spaces for indentation, semicolons to end lines, and formats commas at the start of a new line:
Then there is Isaac Z. Schlueter,author of npm !!
Even on the Jade reference page ... all the code more or less has 2 spaces.
So it is a better thing to adopt the practice and it is almost in all major projects of Node/Express/Jade.
But IMHO who cares as long as you are confident that your code is correct. Maybe one day you will write better and elegant code and become the "benevolent dictator" ;-).
Hope that answers the question :)
Upvotes: 4