.eslintrc.cjs 2.2 KB

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