ESLint is a popular and flexible Javascript linter which will help your team to generate consistent and high-quality code. In this post I will show you how to install and config ESLint for your project in VS Code.

Install ESLint on your machine

First you need to install ESLint globally on your machine. Open your command prompt and type the following command.

npm install -g eslint

ok, now you must have it on your machine.

 

Install ESLint package in vs code

Now, you should install the required package in VS Code. Click on the last square icon on the side bar. Search ESLint in text box and install it.

Install Rule Set

Now, you can go back to your command prompt and before typing this command navigate to your project folder.

eslint --init

After you type this command, you will see the following questions. You can use one of the popular existing styles for your project or a file from your computer. I will choose  “User a popular style guide”.

 

and then it will give you few options to choose from.

The last question is about the format you want your ESLint config file. There isn’t a big difference between them, but the most common one is the JSON format.


Congratulations!!! you’re all set. Now, you can see the red squiggly lines in your code and hover over them and see the error message.