ESlint for React

https://btholt.github.io/complete-intro-to-react-v6/eslint


$ npm install --save-dev \
  eslint \
  eslint-config-prettier


.eslintrc

{
  "extends": ["eslint:recommended", "prettier"],
  "plugins": [],
  "parserOptions": {
    "ecmaVersion": 2021,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true
  }
}


package.json


"lint": "eslint src/**/*.{js,html} --quiet",
"lint:fix": "eslint --fix src/**/*.{js,html}",


.eslintignore


/node_modules/


React


$ npm install --save react react-dom


ESLint + React + Hooks

https://btholt.github.io/complete-intro-to-react-v6/jsx


$ npm install --save-dev \
              eslint-plugin-import \
              eslint-plugin-jsx-a11y \
              eslint-plugin-react \
              eslint-plugin-react-hooks


.eslintrc

{
  "extends": [
    "eslint:recommended",
    "plugin:import/errors",
    "plugin:react/recommended",
    "plugin:jsx-a11y/recommended",
    "plugin:react-hooks/recommended",
    "prettier/react",
    "prettier"
  ],
  "rules": {
    "react/prop-types": 0,
    "react/react-in-jsx-scope": 0
  },
  "plugins": ["react", "import", "jsx-a11y"],
  "parserOptions": {
    "ecmaVersion": 2021,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  }
}