vue.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import type { Linter } from 'eslint';
  2. import { interopDefault } from '../util';
  3. export async function vue(): Promise<Linter.Config[]> {
  4. const [pluginVue, parserVue, parserTs] = await Promise.all([
  5. // @ts-expect-error missing types
  6. interopDefault(import('eslint-plugin-vue')),
  7. interopDefault(import('vue-eslint-parser')),
  8. // @ts-expect-error missing types
  9. interopDefault(import('@typescript-eslint/parser')),
  10. ] as const);
  11. return [
  12. {
  13. files: ['**/*.vue'],
  14. languageOptions: {
  15. parser: parserVue,
  16. parserOptions: {
  17. ecmaFeatures: {
  18. jsx: true,
  19. },
  20. extraFileExtensions: ['.vue'],
  21. parser: parserTs,
  22. sourceType: 'module',
  23. },
  24. },
  25. plugins: {
  26. vue: pluginVue,
  27. },
  28. processor: pluginVue.processors['.vue'],
  29. rules: {
  30. ...pluginVue.configs.base.rules,
  31. ...pluginVue.configs['vue3-essential'].rules,
  32. ...pluginVue.configs['vue3-strongly-recommended'].rules,
  33. ...pluginVue.configs['vue3-recommended'].rules,
  34. 'vue/attribute-hyphenation': [
  35. 'error',
  36. 'always',
  37. {
  38. ignore: [],
  39. },
  40. ],
  41. 'vue/attributes-order': 'off',
  42. 'vue/block-order': [
  43. 'error',
  44. {
  45. order: ['script', 'template', 'style'],
  46. },
  47. ],
  48. 'vue/component-name-in-template-casing': ['error', 'PascalCase'],
  49. 'vue/component-options-name-casing': ['error', 'PascalCase'],
  50. 'vue/custom-event-name-casing': ['error', 'camelCase'],
  51. 'vue/define-macros-order': [
  52. 'error',
  53. {
  54. order: [
  55. 'defineOptions',
  56. 'defineProps',
  57. 'defineEmits',
  58. 'defineSlots',
  59. ],
  60. },
  61. ],
  62. 'vue/dot-location': ['error', 'property'],
  63. 'vue/dot-notation': ['error', { allowKeywords: true }],
  64. 'vue/eqeqeq': ['error', 'smart'],
  65. 'vue/html-closing-bracket-newline': 'error',
  66. 'vue/html-indent': 'off',
  67. // 'vue/html-indent': ['error', 2],
  68. 'vue/html-quotes': ['error', 'double'],
  69. 'vue/html-self-closing': [
  70. 'error',
  71. {
  72. html: {
  73. component: 'always',
  74. normal: 'never',
  75. void: 'always',
  76. },
  77. math: 'always',
  78. svg: 'always',
  79. },
  80. ],
  81. 'vue/max-attributes-per-line': 'off',
  82. 'vue/multi-word-component-names': 'off',
  83. 'vue/multiline-html-element-content-newline': 'error',
  84. 'vue/no-empty-pattern': 'error',
  85. 'vue/no-extra-parens': ['error', 'functions'],
  86. 'vue/no-irregular-whitespace': 'error',
  87. 'vue/no-loss-of-precision': 'error',
  88. 'vue/no-reserved-component-names': 'off',
  89. 'vue/no-restricted-syntax': [
  90. 'error',
  91. 'DebuggerStatement',
  92. 'LabeledStatement',
  93. 'WithStatement',
  94. ],
  95. 'vue/no-restricted-v-bind': ['error', '/^v-/'],
  96. 'vue/no-sparse-arrays': 'error',
  97. 'vue/no-unused-refs': 'error',
  98. 'vue/no-useless-v-bind': 'error',
  99. 'vue/object-shorthand': [
  100. 'error',
  101. 'always',
  102. {
  103. avoidQuotes: true,
  104. ignoreConstructors: false,
  105. },
  106. ],
  107. 'vue/one-component-per-file': 'error',
  108. 'vue/prefer-import-from-vue': 'error',
  109. 'vue/prefer-separate-static-class': 'error',
  110. 'vue/prefer-template': 'error',
  111. 'vue/prop-name-casing': ['error', 'camelCase'],
  112. 'vue/require-default-prop': 'error',
  113. 'vue/require-explicit-emits': 'error',
  114. 'vue/require-prop-types': 'off',
  115. 'vue/script-setup-uses-vars': 'error',
  116. 'vue/singleline-html-element-content-newline': 'off',
  117. 'vue/space-infix-ops': 'error',
  118. 'vue/space-unary-ops': ['error', { nonwords: false, words: true }],
  119. 'vue/v-on-event-hyphenation': [
  120. 'error',
  121. 'always',
  122. {
  123. autofix: true,
  124. ignore: [],
  125. },
  126. ],
  127. },
  128. },
  129. ];
  130. }