eslint.config.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import antfu from '@antfu/eslint-config'
  2. import pluginVitest from '@vitest/eslint-plugin'
  3. import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
  4. import pluginPlaywright from 'eslint-plugin-playwright'
  5. import pluginVue from 'eslint-plugin-vue'
  6. // To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
  7. // import { configureVueProject } from '@vue/eslint-config-typescript'
  8. // configureVueProject({ scriptLangs: ['ts', 'tsx'] })
  9. // More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
  10. export default antfu(
  11. {
  12. type: 'app',
  13. vue: true, // 启用 Vue 支持
  14. typescript: true, // 启用 TS 支持
  15. jsonc: true, // 支持 .json/.jsonc
  16. yaml: true, // 支持 .yaml
  17. markdown: true, // 支持 .md 中代码块
  18. test: true, // 启用 Vitest 支持
  19. stylistic: {
  20. indent: 2,
  21. semi: false,
  22. quotes: 'single',
  23. jsx: true,
  24. },
  25. ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
  26. rules: {
  27. 'vue/multi-word-component-names': 'off', // 🚫 禁用多单词组件名规则
  28. },
  29. },
  30. pluginVue.configs['flat/essential'],
  31. // ✅ 添加 vue/block-lang 规则
  32. {
  33. rules: {
  34. 'vue/block-lang': [
  35. 'error',
  36. {
  37. script: {
  38. lang: ['ts', 'tsx'], // ✅ 支持 tsx
  39. },
  40. },
  41. ],
  42. },
  43. },
  44. // ✅ 测试文件配置
  45. {
  46. ...pluginVitest.configs.recommended,
  47. files: ['src/**/__tests__/*'],
  48. },
  49. // ✅ Playwright 配置
  50. {
  51. ...pluginPlaywright.configs['flat/recommended'],
  52. files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
  53. },
  54. skipFormatting,
  55. )