.eslintrc.js 2.2 KB

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