Skip to content

Instantly share code, notes, and snippets.

@gapurov
Last active December 10, 2018 13:19
Show Gist options
  • Save gapurov/32eb2927312f671abb6322ddab074acf to your computer and use it in GitHub Desktop.
Save gapurov/32eb2927312f671abb6322ddab074acf to your computer and use it in GitHub Desktop.
eslint + prettier config react
{
"extends": [
"airbnb",
"prettier",
"prettier/react"
],
"parser": "babel-eslint",
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"rules": {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"no-use-before-define": [
"error",
{
"functions": false
}
],
"no-shadow": "off",
"constructor-super": "warn",
"valid-typeof": "warn",
"prettier/prettier": [
"error",
{
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 120,
"semi": true
}
],
"react/jsx-filename-extension": [
"error",
{
"extensions": [
".js",
".jsx"
]
}
],
"import/no-extraneous-dependencies": [
"off"
],
"react/prefer-stateless-function": [
"off"
],
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": []
}
],
"react-hooks/rules-of-hooks": "error"
},
"plugins": [
"prettier",
"react-hooks"
]
}

Install packages

  1. npm install -D eslint prettier
  2. npx install-peerdeps --dev eslint-config-airbnb
  3. npm install -D eslint-config-prettier eslint-plugin-prettier
  4. npm install -D eslint-plugin-react-hooks@next

Add to the settings.json

  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.formatOnSave": false
  },
  "eslint.autoFixOnSave": true,
  "eslint.alwaysShowStatus": false,
  "javascript.validate.enable": false,
  "javascript.format.enable": true,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment