Skip to content

Instantly share code, notes, and snippets.

@sanjaykapilesh
Last active August 7, 2021 05:44
Show Gist options
  • Save sanjaykapilesh/1bd510664f4c8915299614ba2a112f70 to your computer and use it in GitHub Desktop.
Save sanjaykapilesh/1bd510664f4c8915299614ba2a112f70 to your computer and use it in GitHub Desktop.
Typescript Eslintrc Configuration
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"airbnb",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint",
"react-hooks"
],
"settings": {
"import/resolver": {
"typescript": {},
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"rules": {
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
"react/jsx-filename-extension": [ "warn", {"extensions": [".tsx"]} ],
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never",
"tsx": "never"
}
],
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/explicit-function-return-type": [
"off",
{
"allowExpressions": true
}
],
"max-len": ["warn", { "code": 120 }],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"import/prefer-default-export": "off",
"react/prop-types": "off",
"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true,
"types": {
"{}": false
}
}
]
}
}

Setup

  1. Install Eslint npm install eslint --save-dev
  2. Generate .eslinrc.json npx eslint --init
  3. Choose the required options
  4. Install the extra dependencies

npm install eslint-import-resolver-typescript prettier eslint-config-prettier --save-dev

André Borba Netto Assis Blog on Eslint with Typescript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment