Skip to content

Instantly share code, notes, and snippets.

@avermeulen
Forked from Unalo/Eslint.md
Last active March 30, 2021 10:33
Show Gist options
  • Save avermeulen/bb8447862f3f66861a88fab8609a5f3e to your computer and use it in GitHub Desktop.
Save avermeulen/bb8447862f3f66861a88fab8609a5f3e to your computer and use it in GitHub Desktop.

Using ESLint with VS Code

ESLint is a tool for “linting” your code. It analyze your code and warn you of potential errors.

Installing ESLint

In order for it to work, you need to configure it with specific rules. Luckily it provides an ESLint configuration that anyone can use.

  1. To use ESLint you will need to install Node.js
  2. Inside your current project. Initialize npm configuration using the command below:
npm init -y
  1. 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
  1. Now create .eslintrc.js with the following contents
module.exports = {
    "extends": "standard"
    };

Setup ESLint in VS Code

  1. Open VS Code and press Ctrl + Shift + X
  2. Type ESLint in the search bar
  3. Find ESLint in the results, then click the Install
  4. Go ahead and close (restart) VS Code and then re-open it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment