umma.dev

Setting Up ESLint

Steps to take to add ESLint to JavaScript projects.

What is ESLint?

It’s a linter; think syntax correction, cleaning up your code, errors etc.

VSCode Extension

To install it, head over to either the VSCode market place or click on the extensions icon on the left hand side within VSCode (squares icon) and search for ESLint.

Within your JavaScript project, head over to package.json and add the following:

You can also download it via npm install eslint -g, which will install it globally. In your root project you will need to pass the command eslint --init.

In your project you can

scripts: {
  "lint": "eslint"
}
npm run lint

Additional Configurations

In the root of your project, you can create an .eslintrc.json file.

Example config of the file

{
  "env": {
    "brower": true,
    "es6": true
  },
  ...
  "rules": {
    no-empty: 0;
    no-irregular-whitespace: 0;
  }
}