Setting up ESLint on VS Code with Airbnb JavaScript Style Guide

  1. cd coding-directory
  2. npm init -y
  3. npm install --save-dev --save-exact eslint eslint-config-airbnb-base eslint-plugin-import
  4. Create .eslintrc.js file with following content:
module.exports={
      “extends”: “airbnb-base”,
      “env”: {
      “browser”: true,
      “node”: true
      },
      “parser”:”babel-eslint”,
}
  1. Install ESLint plugin (extension) in Visual Studio Code (shift + command + x / VScode -> View -> Extension)
  2. Restart Visual Studio Code

To check result

if you get error like

ESLint Parsing error: Unexpected token

Solved it by installing babel-eslint using npm

npm install babel-eslint --save-dev

Secondly, add this configuration in .eslintrc file

{
   "parser":"babel-eslint"
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s