.eslintrc.cjs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. ],
  46. // 关闭名称校验
  47. 'vue/multi-word-component-names': 'off',
  48. // 非生产环境启用 debugger
  49. 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
  50. // Best Practices
  51. eqeqeq: 'off',
  52. // Stylistic Issues
  53. // 强制可嵌套的块的最大深度
  54. 'max-depth': ['error', 5],
  55. // 强制函数最大代码行数
  56. 'max-lines-per-function': [
  57. 'error',
  58. {
  59. max: 150,
  60. skipBlankLines: true
  61. }
  62. ],
  63. // 强制回调函数最大嵌套深度
  64. 'max-nested-callbacks': ['error', { max: 10 }],
  65. // 强制函数定义中最多允许的参数数量
  66. 'max-params': ['error', { max: 5 }],
  67. // 强制每一行中所允许的最大语句数量
  68. 'max-statements-per-line': ['error', { max: 1 }],
  69. // 三目运算符换行
  70. 'multiline-ternary': ['error', 'never'],
  71. // 传值给组件时的使用 kebab-case
  72. 'vue/v-on-event-hyphenation': ['warn', 'always', {
  73. autofix: true,
  74. ignore: []
  75. }]
  76. }
  77. }