.eslintrc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. {
  2. "extends": [
  3. "plugin:@typescript-eslint/recommended",
  4. "eslint-config-airbnb-base",
  5. "@vue/typescript/recommended",
  6. "plugin:vue/vue3-recommended",
  7. "plugin:vue-scoped-css/base",
  8. "plugin:prettier/recommended"
  9. ],
  10. "env": {
  11. // 浏览器全局变量
  12. "browser": true,
  13. "node": true,
  14. "jest": true,
  15. // 启用 ES6 语法支持以及新的 ES6 全局变量或类型
  16. "es6": true
  17. },
  18. "globals": {
  19. "defineProps": "readonly",
  20. "defineEmits": "readonly"
  21. },
  22. "plugins": ["vue", "@typescript-eslint"],
  23. "parserOptions": {
  24. // parser指定解析器,默认的为espree。babel-eslint是一个Babel parser的包装器,这个包装器使得 Babel parser 可以和 ESLint 协调工作
  25. "parser": "@typescript-eslint/parser",
  26. // 指定来源的类型,'script' (默认) 或 'module'(如果你的代码是 ECMAScript 模块)
  27. "sourceType": "module"
  28. // "allowImportExportEverywhere": true,
  29. // "ecmaFeatures": {
  30. // "jsx": true
  31. // }
  32. },
  33. "settings": {
  34. "import/extensions": [".js", ".jsx", ".ts", ".tsx"]
  35. },
  36. "rules": {
  37. "no-console": "off",
  38. "no-continue": "off",
  39. "no-restricted-syntax": "off",
  40. "no-plusplus": "off",
  41. "no-param-reassign": "off",
  42. "no-shadow": "off",
  43. "guard-for-in": "off",
  44. "import/extensions": "off",
  45. "import/no-unresolved": "off",
  46. "import/no-extraneous-dependencies": "off",
  47. "import/prefer-default-export": "off",
  48. "import/first": "off", // https://github.com/vuejs/vue-eslint-parser/issues/58
  49. "@typescript-eslint/no-explicit-any": "off",
  50. "@typescript-eslint/explicit-module-boundary-types": "off",
  51. "vue/first-attribute-linebreak": 0,
  52. "@typescript-eslint/no-unused-vars": [
  53. "error",
  54. {
  55. "argsIgnorePattern": "^_",
  56. "varsIgnorePattern": "^_"
  57. }
  58. ],
  59. "no-unused-vars": [
  60. "error",
  61. {
  62. "argsIgnorePattern": "^_",
  63. "varsIgnorePattern": "^_"
  64. }
  65. ],
  66. "no-use-before-define": "off",
  67. "@typescript-eslint/no-use-before-define": "off",
  68. "@typescript-eslint/ban-ts-comment": "off",
  69. "@typescript-eslint/ban-types": "off",
  70. "class-methods-use-this": "off" // 因为AxiosCancel必须实例化而能静态化所以加的规则,如果有办法解决可以取消
  71. },
  72. "overrides": [
  73. {
  74. "files": ["*.vue"],
  75. "rules": {
  76. // "vue/component-name-in-template-casing": [2, "kebab-case"],//模板中是否将组件名称强制转化成横杠连接的命名
  77. "vue/require-default-prop": 0,
  78. "vue/multi-word-component-names": 0,
  79. "vue/no-reserved-props": 0,
  80. "vue/no-v-html": 0,
  81. "vue-scoped-css/enforce-style-type": ["error", { "allows": ["scoped"] }],
  82. }
  83. },
  84. {
  85. "files": ["*.ts", "*.tsx"], // https://github.com/typescript-eslint eslint-recommended
  86. "rules": {
  87. "constructor-super": "off", // ts(2335) & ts(2377)
  88. "getter-return": "off", // ts(2378)
  89. "no-const-assign": "off", // ts(2588)
  90. // 禁止function定义中出现重名参数
  91. "no-dupe-args": "off", // ts(2300)
  92. "no-dupe-class-members": "off", // ts(2393) & ts(2300)
  93. "no-dupe-keys": "off", // ts(1117)
  94. "no-func-assign": "off", // ts(2539)
  95. "no-import-assign": "off", // ts(2539) & ts(2540)
  96. "no-new-symbol": "off", // ts(2588)
  97. "no-obj-calls": "off", // ts(2349)
  98. "no-redeclare": "off", // ts(2451)
  99. "no-setter-return": "off", // ts(2408)
  100. "no-this-before-super": "off", // ts(2376)
  101. "no-undef": "off", // ts(2304)
  102. //禁止在return、throw、continue、break语句之后出现不可达代码
  103. "no-unreachable": "off", // ts(7027)
  104. "no-unsafe-negation": "off", // ts(2365) & ts(2360) & ts(2358)
  105. "no-var": "error", // ts transpiles let/const to var, so no need for vars any more
  106. "prefer-const": "error", // ts provides better types with const
  107. "prefer-rest-params": "error", // ts provides better types with rest args over arguments
  108. "prefer-spread": "error", // ts transpiles spread to apply, so no need for manual apply
  109. "valid-typeof": "off", // ts(2367)
  110. "vue/v-on-event-hyphenation":"off", // 事件名中横线
  111. "vue/no-dupe-keys":"true" // 禁止出现重复的属性
  112. }
  113. }
  114. ]
  115. }