.eslintrc.json 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {
  2. "root": true,
  3. "env": {
  4. "browser": true,
  5. "es2021": true
  6. },
  7. "settings": {
  8. //自动发现React的版本,从而进行规范react代码
  9. "react": {
  10. "pragma": "React",
  11. "version": "detect"
  12. }
  13. },
  14. "extends": [
  15. // "eslint:recommended",
  16. "plugin:@typescript-eslint/recommended",
  17. "prettier",
  18. "plugin:prettier/recommended"
  19. ],
  20. "parser": "@typescript-eslint/parser", // 定义ESLint的解析器
  21. "parserOptions": {
  22. "parser": "@typescript-eslint/parser",
  23. "ecmaVersion": "latest",
  24. "sourceType": "module",
  25. "ecmaFeatures": {
  26. "jsx": true
  27. }
  28. },
  29. "plugins": ["@typescript-eslint", "eslint-plugin-react"],
  30. // typescript-eslint https://typescript-eslint.io/getting-started
  31. // eslint https://zh-hans.eslint.org/docs/latest/
  32. // prettier https://prettier.io/docs/en/
  33. // off或0 关闭规则; warn或1 启用并警告(不影响现有代码); error或2 启用并报错(错误代码1)
  34. "rules": {
  35. "@typescript-eslint/ban-ts-ignore": "off",
  36. "@typescript-eslint/explicit-function-return-type": "off",
  37. "@typescript-eslint/no-explicit-any": "off",
  38. "@typescript-eslint/no-var-requires": "off",
  39. "@typescript-eslint/no-empty-function": "off",
  40. "@typescript-eslint/no-use-before-define": "off",
  41. "@typescript-eslint/ban-ts-comment": "off",
  42. "@typescript-eslint/ban-types": "off",
  43. "@typescript-eslint/no-non-null-assertion": "off",
  44. "@typescript-eslint/explicit-module-boundary-types": "off",
  45. "@typescript-eslint/no-this-alias": "off",
  46. "@typescript-eslint/no-empty-object-type": "off",
  47. "@typescript-eslint/no-unused-vars": [
  48. "off",
  49. {
  50. "argsIgnorePattern": "^_",
  51. "varsIgnorePattern": "^_"
  52. }
  53. ],
  54. "prettier/prettier": [
  55. "off",
  56. {
  57. "endOfLine": "auto"
  58. }
  59. ],
  60. // 定义了未使用的变量
  61. "no-unused-vars": [
  62. "off",
  63. {
  64. "argsIgnorePattern": "^_",
  65. "varsIgnorePattern": "^_"
  66. }
  67. ],
  68. "no-var": "off",
  69. // 单引号
  70. "quotes": ["error", "single"],
  71. // 尾随逗号
  72. "comma-dangle": ["error", "never"],
  73. // 在非空文件的末尾至少有一个换行(或没有换行)的末尾至少有一个换行
  74. "eol-last": ["error", "always"],
  75. // 禁止出现多行空行
  76. "no-multiple-empty-lines": ["error", { "max": 1 }]
  77. }
  78. }