使用 4 个空格而不是 2 个空格的原因?

Reason for using 4-spaces instead of 2-spaces?

HapiJS 支持使用 4-space 缩进有什么理由吗?

来源:http://hapijs.com/styleguide

简短回答:没有比其他人更好的理由了——风格指南通常只是项目维护者的规则。他们必须采用一些惯例,这就是选择。作为用户,你真的不需要关心。

长答案: Hapi 是一个很棒的框架,由沃尔玛的员工构建。特别是一个名叫 Eran Hammer 的人,他对 Express, another server framework for Node. It is somewhat opinionated in general, it was effectively created in an environment of opinion, not to mention a large company (which means it desperately needed a convention). That said, you can safely use the Hapi API with any indentation you want, including tabs, though. Likewise, the Hapi internals could have been written the same way. Their specific choice likely comes down to established tools or conventions already in use at the company. Many different projects make different choices for a variety of reasons. In my experience, many large JavaScript applications go with 2 spaces and the Node.js core itself is written with 2 做出的一些架构选择感到不满。但是那些不这样做的人没有错。