.eslintrc.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. module.exports = {
  2. root: true,
  3. env: {
  4. node: true,
  5. },
  6. extends: [
  7. 'vue-global-api',
  8. 'plugin:vue/vue3-recommended',
  9. 'eslint:recommended',
  10. 'plugin:@typescript-eslint/recommended',
  11. '@vue/typescript/recommended',
  12. 'plugin:prettier/recommended',
  13. ],
  14. parser: 'vue-eslint-parser',
  15. parserOptions: {
  16. parser: {
  17. js: 'espree',
  18. ts: '@typescript-eslint/parser',
  19. '<template>': 'espree',
  20. },
  21. sourceType: 'module',
  22. ecmaFeatures: {
  23. jsx: true,
  24. tsx: true,
  25. },
  26. warnOnUnsupportedTypeScriptVersion: false,
  27. },
  28. rules: {
  29. 'no-undef': 'off',
  30. 'no-console': 'off',
  31. 'no-debugger': 'off',
  32. 'prettier/prettier': 'warn',
  33. 'prefer-template': 'error',
  34. 'vue/no-reserved-component-names': 'off',
  35. '@typescript-eslint/no-this-alias': 'off',
  36. '@typescript-eslint/no-explicit-any': 'off',
  37. '@typescript-eslint/no-var-requires': 'off',
  38. '@typescript-eslint/no-empty-function': 'off',
  39. '@typescript-eslint/ban-ts-comment': 'off',
  40. 'vue/no-v-html': 'off',
  41. 'vue/html-self-closing': [
  42. 'error',
  43. {
  44. html: {
  45. void: 'any',
  46. normal: 'any',
  47. component: 'always',
  48. },
  49. svg: 'always',
  50. math: 'always',
  51. },
  52. ],
  53. // 多字组件名称
  54. 'vue/multi-word-component-names': 'off',
  55. // Vue.js风格指南(https://cn.vuejs.org/v2/style-guide/)
  56. // Vue组件排序
  57. 'vue/order-in-components': [
  58. 'warn',
  59. {
  60. order: [
  61. 'el',
  62. 'name',
  63. 'key',
  64. 'parent',
  65. 'functional',
  66. ['delimiters', 'comments'],
  67. ['components', 'directives', 'filters'],
  68. 'extends',
  69. 'mixins',
  70. ['provide', 'inject'],
  71. 'ROUTER_GUARDS',
  72. 'layout',
  73. 'middleware',
  74. 'validate',
  75. 'scrollToTop',
  76. 'transition',
  77. 'loading',
  78. 'inheritAttrs',
  79. 'model',
  80. ['props', 'propsData'],
  81. 'emits',
  82. 'setup',
  83. 'fetch',
  84. 'asyncData',
  85. 'data',
  86. 'head',
  87. 'computed',
  88. 'watch',
  89. 'watchQuery',
  90. 'LIFECYCLE_HOOKS',
  91. 'methods',
  92. ['template', 'render'],
  93. 'renderError',
  94. ],
  95. },
  96. ],
  97. // Vue属性排序
  98. 'vue/attributes-order': [
  99. 'warn',
  100. {
  101. order: [
  102. 'DEFINITION',
  103. 'LIST_RENDERING',
  104. 'CONDITIONALS',
  105. 'RENDER_MODIFIERS',
  106. 'GLOBAL',
  107. 'UNIQUE',
  108. 'TWO_WAY_BINDING',
  109. 'OTHER_DIRECTIVES',
  110. 'OTHER_ATTR',
  111. 'EVENTS',
  112. 'CONTENT',
  113. ],
  114. alphabetical: true, //字母顺序
  115. },
  116. ],
  117. },
  118. overrides: [
  119. {
  120. files: [
  121. '**/__tests__/*.{j,t}s?(x)',
  122. '**/tests/unit/**/*.spec.{j,t}s?(x)',
  123. ],
  124. env: {
  125. jest: true,
  126. },
  127. },
  128. {
  129. files: [
  130. '**/__tests__/*.{j,t}s?(x)',
  131. '**/tests/unit/**/*.spec.{j,t}s?(x)',
  132. ],
  133. env: {
  134. jest: true,
  135. },
  136. },
  137. ],
  138. }