Search code examples
node.jsexpresswebstorm

Webstorm nodejs conventions spaces


I read that the convention of node js of spaces is double spaces, but by default it is 4 spaces, how to configure it?

It is:

if ('development' == app.get('env')) {
    app.use(express.errorHandler());
}

should be this way:

if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

Solution

  • That's not a "convention" - that's called code style; and more specifically, it looks like it's the NPM Coding Style, as it's followed by lots of Node developers out there.

    You can customize this easily by going to Settings -> Code Style -> JavaScript in WebStorm.

    P.S.: I personally like a lot the jQuery Code Style - it's more readable than any other.