Skip to content

Instantly share code, notes, and snippets.

@Sergih28
Created August 4, 2021 09:45
Show Gist options
  • Save Sergih28/fbedd3c05ad6caa3ea160e16074a3ba2 to your computer and use it in GitHub Desktop.
Save Sergih28/fbedd3c05ad6caa3ea160e16074a3ba2 to your computer and use it in GitHub Desktop.
eslint config
{
"env": {
"browser": true,
"es2021": true,
"node": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint", "import"],
"rules": {
// disable the rule for all files
"@typescript-eslint/explicit-function-return-type": "off",
// suppress errors for missing 'import React' in files
"react/react-in-jsx-scope": "off",
// turn on errors for missing imports
"import/no-unresolved": "error",
"no-console": "error",
"quotes": ["error", "single"],
"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true,
"types": {
"{}": false
}
}
],
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
["sibling", "parent", "internal", "index"],
"object"
],
"pathGroups": [
{
"pattern": "react",
"group": "external",
"position": "before"
},
{
"pattern": "*.css",
"group": "object",
"position": "after"
},
{
"pattern": "assets/**",
"group": "internal",
"position": "after"
},
{
"pattern": "pages/**",
"group": "internal",
"position": "after"
},
{
"pattern": "components/**",
"group": "internal",
"position": "after"
},
{
"pattern": "types/**",
"group": "internal",
"position": "after"
},
{
"pattern": "redux/**",
"group": "internal",
"position": "after"
},
{
"pattern": "styles/**",
"group": "internal",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["react"],
"newlines-between": "always",
"alphabetize": {
"order": "asc" /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */,
"caseInsensitive": true /* ignore case. Options: [true, false] */
}
}
]
},
"overrides": [
{
// enable the rule specifically for TypeScript files
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-function-return-type": ["error"]
}
}
],
"settings": {
"react": {
"version": "detect"
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": { "node": { "paths": ["./", "./src"] } }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment