Skip to content

Instantly share code, notes, and snippets.

@abdellatifLabr
Last active February 16, 2022 08:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save abdellatifLabr/0ff7f5b2dcf0168fed60099b065b441c to your computer and use it in GitHub Desktop.

React eslint setup

$ npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-config-airbnb eslint-plugin-html @trivago/prettier-plugin-sort-imports

.eslintrc

{
  "env": {
    "browser": true
  },
  "extends": ["airbnb", "prettier", "prettier/react"],
  "plugins": ["prettier", "html", "react-hooks"],
  "rules": {
    "prettier/prettier": ["error", {
      "endOfLine": "auto"
    }],
    "global-require": "off",
    "import/no-dynamic-require": "off",
    "react/no-unescaped-entities": "off",
    "react/jsx-filename-extension": "off"
  }
}

.prettierrc

{
  "singleQuote": true,
  "semi": true,
  "endOfLine": "auto",
  "importOrder": [
    "^~/lib(.*)$",
    "^~/routes(.*)$",
    "^~/pages(.*)$",
    "^~/components(.*)$",
    "^~/store(.*)$",
    "^~/utils(.*)$",
    "^[./]"
  ],
  "importOrderSeparation": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment