TS项目配置eslint

需要使用以下包:

  • @typescript-eslint/eslint-plugin
  • @typescript-eslint/parser
  • eslint-plugin-react
  • eslint-plugin-react-hooks

ESLINT 配置:

    "env": {
      "browser": true,
      "node": true
    },
    "parser": "@typescript-eslint/parser",
    "extends": [
      "plugin:@typescript-eslint/recommended"
    ],
    "plugins": [
      "react",
      "@typescript-eslint",
      "react-hooks"
    ],
    "rules": {
      "jsx-a11y/alt-text": 0,
      ...
    }

项目的 .vscode/settings.json

  "eslint.enable": true,
  "eslint.options": {
    "extensions": [".js", ".jsx", ".ts", ".tsx"]
  },
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "html",
    "typescript",
    "typescriptreact"
  ],
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }

你可能感兴趣的:(TS项目配置eslint)