.eslintrc.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. 'vue/no-reserved-component-names': 'off',
  34. '@typescript-eslint/no-this-alias': 'off',
  35. '@typescript-eslint/no-explicit-any': 'off',
  36. '@typescript-eslint/no-var-requires': 'off',
  37. '@typescript-eslint/no-empty-function': 'off',
  38. '@typescript-eslint/ban-ts-comment': 'off',
  39. 'vue/no-v-html': 'off',
  40. 'vue/html-self-closing': [
  41. 'error',
  42. {
  43. html: {
  44. void: 'any',
  45. normal: 'any',
  46. component: 'always',
  47. },
  48. svg: 'always',
  49. math: 'always',
  50. },
  51. ],
  52. // 多字组件名称
  53. 'vue/multi-word-component-names': 'off',
  54. // Vue.js风格指南(https://cn.vuejs.org/v2/style-guide/)
  55. // Vue组件排序
  56. 'vue/order-in-components': [
  57. 'warn',
  58. {
  59. order: [
  60. 'el',
  61. 'name',
  62. 'key',
  63. 'parent',
  64. 'functional',
  65. ['delimiters', 'comments'],
  66. ['components', 'directives', 'filters'],
  67. 'extends',
  68. 'mixins',
  69. ['provide', 'inject'],
  70. 'ROUTER_GUARDS',
  71. 'layout',
  72. 'middleware',
  73. 'validate',
  74. 'scrollToTop',
  75. 'transition',
  76. 'loading',
  77. 'inheritAttrs',
  78. 'model',
  79. ['props', 'propsData'],
  80. 'emits',
  81. 'setup',
  82. 'fetch',
  83. 'asyncData',
  84. 'data',
  85. 'head',
  86. 'computed',
  87. 'watch',
  88. 'watchQuery',
  89. 'LIFECYCLE_HOOKS',
  90. 'methods',
  91. ['template', 'render'],
  92. 'renderError',
  93. ],
  94. },
  95. ],
  96. // Vue属性排序
  97. 'vue/attributes-order': [
  98. 'warn',
  99. {
  100. order: [
  101. 'DEFINITION',
  102. 'LIST_RENDERING',
  103. 'CONDITIONALS',
  104. 'RENDER_MODIFIERS',
  105. 'GLOBAL',
  106. 'UNIQUE',
  107. 'TWO_WAY_BINDING',
  108. 'OTHER_DIRECTIVES',
  109. 'OTHER_ATTR',
  110. 'EVENTS',
  111. 'CONTENT',
  112. ],
  113. alphabetical: true, //字母顺序
  114. },
  115. ],
  116. },
  117. overrides: [
  118. {
  119. files: [
  120. '**/__tests__/*.{j,t}s?(x)',
  121. '**/tests/unit/**/*.spec.{j,t}s?(x)',
  122. ],
  123. env: {
  124. jest: true,
  125. },
  126. },
  127. {
  128. files: [
  129. '**/__tests__/*.{j,t}s?(x)',
  130. '**/tests/unit/**/*.spec.{j,t}s?(x)',
  131. ],
  132. env: {
  133. jest: true,
  134. },
  135. },
  136. ],
  137. }