1. Install typescript plug-ins for Eslint and Eslint

yarn add -D eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
Copy the code

2. Install Airbnb rule plug-ins and extensions (Currently Airbnb is the most used rule)

yarn add -D eslint-config-airbnb-typescript
yarn add -D eslint-plugin-import \
            eslint-plugin-jsx-a11y \
            eslint-plugin-react \
            eslint-plugin-react-hooks
Copy the code

3. New.eslintrc.jsFile, custom configuration

module.exports = {
  root: true.env: {
    browser: true.es2021: true,},extends: ['airbnb-typescript'].parserOptions: {
    project: './tsconfig.json',},rules: {
    // The weight of rules added here is the highest. For example, in Airbnb rules, unused variables will report an error, which is changed to a warning
    "@typescript-eslint/no-unused-vars": ["warn"]}};Copy the code

4. New.eslintignoreFiles, ignore files that you do not want to be examined

# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist
# don't lint eslint config
.eslintrc.js
Copy the code