eslint.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. // TS 自身已检查未定义变量,ESLint 的 no-undef 对 auto-import 全局变量会误报
  37. 'no-undef': 'off',
  38. },
  39. },
  40. ]