.eslintrc.cjs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* eslint-env node */
  2. require('@rushstack/eslint-patch/modern-module-resolution')
  3. module.exports = {
  4. root: true,
  5. extends: [
  6. 'plugin:vue/vue3-essential',
  7. 'eslint:recommended',
  8. '@vue/eslint-config-typescript',
  9. '@vue/eslint-config-prettier/skip-formatting'
  10. ],
  11. overrides: [
  12. {
  13. files: ['cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', 'cypress/support/**/*.{js,ts,jsx,tsx}'],
  14. extends: ['plugin:cypress/recommended']
  15. }
  16. ],
  17. parserOptions: {
  18. ecmaVersion: 'latest'
  19. },
  20. rules: {
  21. // JavaScript/ESLint 推荐的规则
  22. // 'no-console': 'warn', // 不允许使用 console.log 等
  23. 'no-unused-vars': 'warn', // 不允许存在未使用的变量
  24. 'no-undef': 'error', // 不允许使用未定义的变量
  25. 'no-var': 'error', //不允许使用var定义变量
  26. // Vue/ESLint 推荐的规则
  27. 'vue/html-indent': ['error', 2], // HTML 缩进为 2 个空格
  28. 'vue/attribute-hyphenation': 'error', // 属性名使用连字符形式
  29. 'vue/html-self-closing': 'off', // 关闭自闭合标签要求,根据个人或团队喜好配置
  30. 'vue/max-attributes-per-line': [
  31. 'error',
  32. {
  33. singleline: 3, // 单行最多 3 个属性
  34. multiline: {
  35. max: 1, // 每行最多一个属性
  36. allowFirstLine: false // 不允许属性出现在第一行
  37. }
  38. }
  39. ],
  40. // 'vue/no-v-html': 'off', // 允许使用 v-html 指令
  41. 'vue/no-unused-components': 'warn', // 不允许存在未使用的组件
  42. // TypeScript/ESLint 推荐的规则
  43. '@typescript-eslint/no-unused-vars': 'warn', // 不允许存在未使用的 TypeScript 变量
  44. '@typescript-eslint/explicit-module-boundary-types': 'off', // 允许不显式指定导出函数的返回类型
  45. '@typescript-eslint/no-explicit-any': 'off' // 允许使用 any 类型
  46. }
  47. }