All Articles

JavaScript - Adding ESLint

I am using VS Code as an editor when I work on a JavaScirpt project. You must first install ESLint Plugin from Extensions.

However, when you install ESLint using the plugin, it does not really do much. It throws a lot of erros with red and green underlines that don’t really make sense. I have just found out a very easy way to add ESLint to your project using command lines from your terminal

First, install ESLint
npm install -g eslint

then you gotta init
eslint --init

then your terminal will ask some questions. you have to answer them by using arrows—or j and k if you are familiar with vim—to choose your ESLint options

ESLint questions answered

After answering all the questions, it even asks you if you want to install all the necessary dependencies. You just gotta enter Y, and all the dependencies will be installed. And it automatically creates an .eslintrc.js file like this

module.exports = {
  env: {
    browser: true,
    es6: true,
  },
  extends: ["airbnb"],
  globals: {
    Atomics: "readonly",
    SharedArrayBuffer: "readonly",
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: "module",
  },
  plugins: ["react"],
  rules: {},
};

Aug 8, 2019

AI Enthusiast and a Software Engineer