- Install Eslint
npm install eslint --save-dev
- Generate .eslinrc.json
npx eslint --init
- Choose the required options
- Install the extra dependencies
npm install eslint-import-resolver-typescript prettier eslint-config-prettier --save-dev
{ | |
"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 | |
} | |
} | |
] | |
} | |
} |
npm install eslint --save-dev
npx eslint --init
npm install eslint-import-resolver-typescript prettier eslint-config-prettier --save-dev