O'Reilly logo

Learning Node.js for .NET Developers by Harry Cummings

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Checking code style with ESLint

Although we don't need a compiler, we can still benefit from having the computer perform static analysis of our code. Linting tools are common in many languages for spotting common programming errors that may lead to subtle bugs or confusing code. You may be familiar with CodeRush, StyleCop, and others for .NET, or CheckStyle, Findbugs, Sonar, and others for Java.

We'll be using a JavaScript/ECMAScript linting tool called ESLint. Let's first install it globally:

> npm install -g eslint

Now create a config file to tell ESLint what rules to use as .eslintrc.json:

{ "extends": "eslint:recommended", "env": { "node": true, "es6": true, "mocha": true, "browser": true, "jquery": true }, "rules": { "semi": [2, "always"], "quotes": ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required