.eslintrc.cjs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. module.exports = {
  2. root: true,
  3. env: {
  4. browser: true,
  5. es2021: true
  6. },
  7. globals: {
  8. },
  9. extends: [
  10. 'standard',
  11. './.eslintrc-auto-import.json',
  12. 'plugin:vue/vue3-recommended',
  13. 'plugin:vue-scoped-css/vue3-recommended'
  14. ],
  15. overrides: [],
  16. parserOptions: {
  17. ecmaVersion: 'latest',
  18. sourceType: 'module'
  19. },
  20. plugins: ['vue'],
  21. rules: {
  22. // Possible Errors
  23. // 要求使用 let 或 const 而不是 var
  24. 'no-var': 'error',
  25. // 强制 "for" 循环中更新子句的计数器朝着正确的方向移动
  26. 'for-direction': 'error',
  27. // 强制 getter 函数中出现 return 语句
  28. 'getter-return': 'error',
  29. // 禁止在嵌套的块中出现变量声明或 function 声明
  30. 'no-inner-declarations': 'error',
  31. // 禁止由于 await 或 yield的使用而可能导致出现竞态条件的赋值
  32. 'require-atomic-updates': 'error',
  33. // console 警告
  34. 'no-console': 'warn',
  35. // 禁止出现未使用过的变量
  36. 'no-unused-vars': [
  37. 'warn',
  38. {
  39. args: 'all',
  40. caughtErrors: 'none',
  41. ignoreRestSiblings: true,
  42. vars: 'all'
  43. }
  44. ],
  45. // 关闭名称校验
  46. 'vue/multi-word-component-names': 'off',
  47. // 非生产环境启用 debugger
  48. 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
  49. // Best Practices
  50. eqeqeq: 'off',
  51. // Stylistic Issues
  52. // 强制可嵌套的块的最大深度
  53. 'max-depth': ['error', 5],
  54. // 强制函数最大代码行数
  55. 'max-lines-per-function': [
  56. 'error',
  57. {
  58. max: 150,
  59. skipBlankLines: true
  60. }
  61. ],
  62. // 强制回调函数最大嵌套深度
  63. 'max-nested-callbacks': ['error', { max: 10 }],
  64. // 强制函数定义中最多允许的参数数量
  65. 'max-params': ['error', { max: 5 }],
  66. // 强制每一行中所允许的最大语句数量
  67. 'max-statements-per-line': ['error', { max: 1 }],
  68. // 三目运算符换行
  69. 'multiline-ternary': ['error', 'never'],
  70. // 传值给组件时的使用 kebab-case
  71. 'vue/v-on-event-hyphenation': ['warn', 'always', {
  72. autofix: true,
  73. ignore: []
  74. }]
  75. }
  76. }