.eslintrc.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. module.exports = {
  2. // 使 eslint 支持 node 与 ES6
  3. env: {
  4. browser: true,
  5. es2021: true,
  6. node: true
  7. },
  8. // 引入推荐的语法校验规则
  9. extends: [
  10. 'eslint:recommended',
  11. 'plugin:vue/vue3-recommended',
  12. 'plugin:@typescript-eslint/recommended',
  13. 'plugin:prettier/recommended',
  14. './.eslintrc-auto-import.json'
  15. ],
  16. overrides: [],
  17. // 这里一定要配置对 先使用vue-eslint-parser 再使用@typescript-eslint/parser
  18. // 先解析 <template> 标签中的内容 然后再解析 vue <script> 标签中的 TS 代码
  19. // 选择使用的解析器
  20. parser: 'vue-eslint-parser',
  21. // 解析器的详细配置
  22. parserOptions: {
  23. // 使用最新版 ES 语法
  24. ecmaVersion: 'latest',
  25. // 使用 ESLint TS 解析器
  26. parser: '@typescript-eslint/parser',
  27. // 使用 ES 模块化规范
  28. sourceType: 'module'
  29. },
  30. // 使用的插件
  31. plugins: ['vue', '@typescript-eslint'],
  32. // 自定义规则
  33. rules: {
  34. '@typescript-eslint/no-unused-vars': 'off',
  35. indent: [
  36. 'error',
  37. 4,
  38. {
  39. SwitchCase: 1
  40. }
  41. ],
  42. 'vue/multi-word-component-names': [
  43. 'error',
  44. {
  45. ignores: ['index', 'Header', 'tag', 'Tag'] //需要忽略的组件名
  46. }
  47. ],
  48. '@typescript-eslint/no-var-requires': 'off',
  49. '@typescript-eslint/no-explicit-any': 'off',
  50. semi: 'off',
  51. '@typescript-eslint/no-this-alias': 'off',
  52. 'eslintno-debugger': 'off',
  53. 'vue/no-unused-vars': 'off',
  54. 'vue/no-template-shadow': 'off',
  55. 'vue/require-v-for-key': 'off',
  56. 'vue/no-textarea-mustache': 'off',
  57. 'vue/no-v-html': 'off',
  58. 'no-constant-condition': 'off'
  59. }
  60. };