Getting Started with ESLint

ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs. In many ways, it is similar to JSLint and JSHint with a few exceptions:


You can install ESLint using npm:

npm install -g eslint


If it’s your first time using ESLint, you should set up a config file using --init:

eslint --init

After that, you can run ESLint on any JavaScript file:

eslint test.js test2.js


Note: If you are coming from a version before 1.0.0 please see the migration guide.

After running eslint --init, you’ll have a .eslintrc file in your directory. In it, you’ll see some rules configured like this:

    "rules": {
        "semi": [2, "always"],
        "quotes": [2, "double"]

The names "semi" and "quotes" are the names of rules in ESLint. The number is the error level of the rule and can be one of the three values:

The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the configuration docs).

Your .eslintrc configuration file will also include the line:

    "extends": "eslint:recommended"

Because of this this line, all of the rules marked “” on the rules page will be turned on. Alternatively, you can use configurations that others have created by searching for “eslint-config” on ESLint will not lint your code unless you extend from a shared configuration or explicitly turn rules on in your configuration.

Next Steps