.eslintrc.js 870 B

123456789101112131415161718192021222324252627
  1. module.exports = {
  2. root: true,
  3. env: {
  4. node: true,
  5. browser: true
  6. },
  7. parser: 'vue-eslint-parser', // 解析 .vue 文件
  8. parserOptions: {
  9. parser: '@babel/eslint-parser', // 解析 JS
  10. ecmaVersion: 2020,
  11. sourceType: 'module'
  12. },
  13. extends: [
  14. 'plugin:vue/recommended', // Vue2 官方推荐规则
  15. 'eslint:recommended', // ESLint 推荐规则
  16. 'plugin:prettier/recommended' // 整合 Prettier
  17. ],
  18. rules: {
  19. 'prettier/prettier': 'off',
  20. // 自定义规则 (示例)
  21. 'vue/multi-word-component-names': 'off', // 关闭组件名多单词要求
  22. 'vue/no-v-html': 'off', // 允许使用 v-html
  23. 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  24. 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  25. 'no-prototype-builtins': 'off' // 将 Prettier 警告视为 ESLint 警告
  26. }
  27. }