.eslintrc.cjs 4.4 KB

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