.eslintrc.cjs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*!
  2. * https://eslint.bootcss.com/docs/rules/
  3. * https://eslint.vuejs.org/rules/
  4. */
  5. module.exports = {
  6. root: true,
  7. env: {
  8. browser: true,
  9. node: true,
  10. es6: true
  11. },
  12. parserOptions: {
  13. sourceType: 'module'
  14. },
  15. extends: ['prettier', 'eslint:recommended', 'plugin:prettier/recommended'],
  16. plugins: ['prettier'],
  17. rules: {
  18. 'no-undef': 'off',
  19. 'prettier/prettier': 'warn',
  20. 'no-unused-vars': 'warn',
  21. // 禁用debugger
  22. 'no-debugger': 'warn',
  23. // 禁止出现重复的 case 标签
  24. 'no-duplicate-case': 'warn',
  25. // 禁止出现空语句块
  26. // 'no-empty': 'warn',
  27. // 禁止不必要的括号
  28. 'no-extra-parens': 'off',
  29. // 禁止对 function 声明重新赋值
  30. 'no-func-assign': 'warn',
  31. // 禁止在 return、throw、continue 和 break 语句之后出现不可达代码
  32. 'no-unreachable': 'warn',
  33. // 强制所有控制语句使用一致的括号风格
  34. curly: 'warn',
  35. // 要求 switch 语句中有 default 分支
  36. 'default-case': 'warn',
  37. // 强制尽可能地使用点号
  38. 'dot-notation': 'warn',
  39. // 要求使用 === 和 !==
  40. // eqeqeq: 'warn',
  41. // 禁止 if 语句中 return 语句之后有 else 块
  42. 'no-else-return': 'warn',
  43. // 禁止出现空函数
  44. // 'no-empty-function': 'warn',
  45. // 禁用不必要的嵌套块
  46. 'no-lone-blocks': 'warn',
  47. // 禁止使用多个空格
  48. 'no-multi-spaces': 'warn',
  49. // 禁止多次声明同一变量
  50. 'no-redeclare': 'warn',
  51. // 禁止在 return 语句中使用赋值语句
  52. 'no-return-assign': 'warn',
  53. // 禁用不必要的 return await
  54. 'no-return-await': 'warn',
  55. // 禁止自我赋值
  56. 'no-self-assign': 'warn',
  57. // 禁止自身比较
  58. 'no-self-compare': 'warn',
  59. // 禁止不必要的 catch 子句
  60. 'no-useless-catch': 'warn',
  61. // 禁止多余的 return 语句
  62. 'no-useless-return': 'warn',
  63. // 禁止变量声明与外层作用域的变量同名
  64. 'no-shadow': 'off',
  65. // 允许delete变量
  66. 'no-delete-var': 'off',
  67. // 强制数组方括号中使用一致的空格
  68. 'array-bracket-spacing': 'warn',
  69. // 强制在代码块中使用一致的大括号风格
  70. 'brace-style': 'warn',
  71. // 强制使用骆驼拼写法命名约定
  72. // camelcase: 'warn',
  73. // 强制使用一致的缩进
  74. indent: 'off',
  75. // 强制在 JSX 属性中一致地使用双引号或单引号
  76. // 'jsx-quotes': 'warn',
  77. // 强制可嵌套的块的最大深度4
  78. 'max-depth': 'warn',
  79. // 强制最大行数 300
  80. // "max-lines": ["warn", { "max": 1200 }],
  81. // 强制函数最大代码行数 50
  82. // 'max-lines-per-function': ['warn', { max: 70 }],
  83. // 强制函数块最多允许的的语句数量20
  84. 'max-statements': ['warn', 100],
  85. // 强制回调函数最大嵌套深度
  86. 'max-nested-callbacks': ['warn', 5],
  87. // 强制每一行中所允许的最大语句数量
  88. 'max-statements-per-line': ['warn', { max: 1 }],
  89. // 要求方法链中每个调用都有一个换行符
  90. 'newline-per-chained-call': ['warn', { ignoreChainWithDepth: 3 }],
  91. // 禁止 if 作为唯一的语句出现在 else 语句中
  92. 'no-lonely-if': 'warn',
  93. // 禁止空格和 tab 的混合缩进
  94. 'no-mixed-spaces-and-tabs': 'warn',
  95. // 禁止出现多行空行
  96. 'no-multiple-empty-lines': 'warn',
  97. // 禁止出现;
  98. semi: ['warn', 'never'],
  99. // 强制在块之前使用一致的空格
  100. 'space-before-blocks': 'warn',
  101. // 强制在 function的左括号之前使用一致的空格
  102. // 'space-before-function-paren': ['warn', 'never'],
  103. // 强制在圆括号内使用一致的空格
  104. 'space-in-parens': 'warn',
  105. // 要求操作符周围有空格
  106. 'space-infix-ops': 'warn',
  107. // 强制在一元操作符前后使用一致的空格
  108. 'space-unary-ops': 'warn',
  109. // 强制在注释中 // 或 /* 使用一致的空格
  110. // "spaced-comment": "warn",
  111. // 强制在 switch 的冒号左右有空格
  112. 'switch-colon-spacing': 'warn',
  113. // 强制箭头函数的箭头前后使用一致的空格
  114. 'arrow-spacing': 'warn',
  115. 'no-var': 'warn',
  116. 'prefer-const': 'warn',
  117. 'prefer-rest-params': 'warn',
  118. 'no-useless-escape': 'warn',
  119. 'no-irregular-whitespace': 'warn',
  120. 'no-prototype-builtins': 'warn',
  121. 'no-fallthrough': 'warn',
  122. 'no-extra-boolean-cast': 'warn',
  123. 'no-case-declarations': 'warn',
  124. 'no-async-promise-executor': 'warn'
  125. }
  126. }