.eslintrc.js 2.2 KB

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