ESLint is a tool for “linting” your code. It analyze your code and warn you of potential errors.
In order for it to work, you need to configure it with specific rules. Luckily it provides an ESLint configuration that anyone can use.
- To use ESLint you will need to install Node.js
- Inside your current project. Initialize npm configuration using the command below:
npm init -y
- Now enable support for linting common JavaScript features. Past this in your terminal
npm i -D eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard
- Now create
.eslintrc.js
with the following contents
module.exports = {
"extends": "standard"
};
- Open
VS Code
and pressCtrl + Shift + X
- Type
ESLint
in the search bar - Find ESLint in the results, then click the Install
- Go ahead and close (restart) VS Code and then re-open it.