eslint.config.js 974 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import js from '@eslint/js'
  2. import tseslint from 'typescript-eslint'
  3. import pluginVue from 'eslint-plugin-vue'
  4. import prettierConfig from 'eslint-config-prettier'
  5. export default [
  6. // 忽略目录
  7. { ignores: ['dist/**', 'node_modules/**'] },
  8. // JS 基础规则
  9. js.configs.recommended,
  10. // TypeScript 规则
  11. ...tseslint.configs.recommended,
  12. // Vue3 规则
  13. ...pluginVue.configs['flat/recommended'],
  14. // .vue 文件使用 ts 解析器
  15. {
  16. files: ['**/*.vue'],
  17. languageOptions: {
  18. parserOptions: {
  19. parser: tseslint.parser,
  20. },
  21. },
  22. },
  23. // 关闭与 Prettier 冲突的规则(必须放最后)
  24. prettierConfig,
  25. // 自定义规则
  26. {
  27. languageOptions: {
  28. globals: {
  29. process: 'readonly',
  30. },
  31. },
  32. rules: {
  33. 'vue/multi-word-component-names': 'off',
  34. '@typescript-eslint/no-explicit-any': 'warn',
  35. 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  36. },
  37. },
  38. ]