Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. module.exports = {
  2. root: true,
  3. env: {
  4. browser: true,
  5. node: true,
  6. es2021: true,
  7. },
  8. parser: 'vue-eslint-parser',
  9. extends: [
  10. 'eslint:recommended',
  11. 'plugin:vue/vue3-recommended',
  12. 'plugin:@typescript-eslint/recommended',
  13. 'plugin:prettier/recommended',
  14. // eslint-config-prettier 的缩写
  15. 'prettier',
  16. ],
  17. parserOptions: {
  18. ecmaVersion: 12,
  19. parser: '@typescript-eslint/parser',
  20. sourceType: 'module',
  21. ecmaFeatures: {
  22. jsx: true,
  23. },
  24. },
  25. // eslint-plugin-vue @typescript-eslint/eslint-plugin eslint-plugin-prettier的缩写
  26. plugins: ['vue', '@typescript-eslint', 'prettier'],
  27. rules: {
  28. '@typescript-eslint/ban-ts-ignore': 'off',
  29. '@typescript-eslint/no-unused-vars': 'off',
  30. '@typescript-eslint/explicit-function-return-type': 'off',
  31. '@typescript-eslint/no-explicit-any': 'off',
  32. '@typescript-eslint/no-var-requires': 'off',
  33. '@typescript-eslint/no-empty-function': 'off',
  34. '@typescript-eslint/no-use-before-define': 'off',
  35. '@typescript-eslint/ban-ts-comment': 'off',
  36. '@typescript-eslint/ban-types': 'off',
  37. '@typescript-eslint/no-non-null-assertion': 'off',
  38. '@typescript-eslint/explicit-module-boundary-types': 'off',
  39. 'no-var': 'error',
  40. 'prettier/prettier': 'error',
  41. // 禁止出现console
  42. // 'no-console': 'warn',
  43. // 禁用debugger
  44. 'no-debugger': 'warn',
  45. // 禁止出现重复的 case 标签
  46. 'no-duplicate-case': 'warn',
  47. // 禁止出现空语句块
  48. // 'no-empty': 'warn',
  49. // 禁止不必要的括号
  50. 'no-extra-parens': 'off',
  51. // 禁止对 function 声明重新赋值
  52. 'no-func-assign': 'warn',
  53. // 禁止在 return、throw、continue 和 break 语句之后出现不可达代码
  54. 'no-unreachable': 'warn',
  55. // 强制所有控制语句使用一致的括号风格
  56. curly: 'warn',
  57. // 要求 switch 语句中有 default 分支
  58. 'default-case': 'warn',
  59. // 强制尽可能地使用点号
  60. // 'dot-notation': 'warn',
  61. // 要求使用 === 和 !==
  62. eqeqeq: 'warn',
  63. // 禁止 if 语句中 return 语句之后有 else 块
  64. 'no-else-return': 'warn',
  65. // 禁止出现空函数
  66. 'no-empty-function': 'warn',
  67. // 禁用不必要的嵌套块
  68. 'no-lone-blocks': 'warn',
  69. // 禁止使用多个空格
  70. 'no-multi-spaces': 'warn',
  71. // 禁止多次声明同一变量
  72. 'no-redeclare': 'warn',
  73. // 禁止在 return 语句中使用赋值语句
  74. 'no-return-assign': 'warn',
  75. // 禁用不必要的 return await
  76. 'no-return-await': 'warn',
  77. // 禁止自我赋值
  78. 'no-self-assign': 'warn',
  79. // 禁止自身比较
  80. 'no-self-compare': 'warn',
  81. // 禁止不必要的 catch 子句
  82. 'no-useless-catch': 'warn',
  83. // 禁止多余的 return 语句
  84. 'no-useless-return': 'warn',
  85. // 禁止变量声明与外层作用域的变量同名
  86. 'no-shadow': 'off',
  87. // 允许delete变量
  88. 'no-delete-var': 'off',
  89. // 强制数组方括号中使用一致的空格
  90. 'array-bracket-spacing': 'warn',
  91. // 强制在代码块中使用一致的大括号风格
  92. 'brace-style': 'warn',
  93. // 强制使用骆驼拼写法命名约定
  94. camelcase: 'warn',
  95. // 强制使用一致的缩进
  96. indent: 'off',
  97. // 强制在 JSX 属性中一致地使用双引号或单引号
  98. 'jsx-quotes': 'warn',
  99. // 强制可嵌套的块的最大深度4
  100. 'max-depth': 'warn',
  101. // 强制最大行数 300
  102. // "max-lines": ["warn", { "max": 1200 }],
  103. // 强制函数最大代码行数 50
  104. // 'max-lines-per-function': ['warn', { max: 70 }],
  105. // 强制函数块最多允许的的语句数量20
  106. 'max-statements': ['warn', 100],
  107. // 强制回调函数最大嵌套深度
  108. 'max-nested-callbacks': ['warn', 3],
  109. // 强制函数定义中最多允许的参数数量
  110. 'max-params': ['warn', 3],
  111. // 强制每一行中所允许的最大语句数量
  112. 'max-statements-per-line': ['warn', { max: 1 }],
  113. // 要求方法链中每个调用都有一个换行符
  114. 'newline-per-chained-call': ['warn', { ignoreChainWithDepth: 3 }],
  115. // 禁止 if 作为唯一的语句出现在 else 语句中
  116. 'no-lonely-if': 'warn',
  117. // 禁止空格和 tab 的混合缩进
  118. 'no-mixed-spaces-and-tabs': 'warn',
  119. // 禁止出现多行空行
  120. 'no-multiple-empty-lines': 'warn',
  121. // 禁止出现; //never 绝不
  122. // semi: ['warn', 'never'],
  123. // 强制在块之前使用一致的空格
  124. 'space-before-blocks': 'warn',
  125. // 强制在 function的左括号之前使用一致的空格
  126. // 'space-before-function-paren': ['warn', 'never'],
  127. // 强制在圆括号内使用一致的空格
  128. 'space-in-parens': 'warn',
  129. // 要求操作符周围有空格
  130. 'space-infix-ops': 'warn',
  131. // 强制在一元操作符前后使用一致的空格
  132. 'space-unary-ops': 'warn',
  133. // 强制在注释中 // 或 /* 使用一致的空格
  134. // "spaced-comment": "warn",
  135. // 强制在 switch 的冒号左右有空格
  136. 'switch-colon-spacing': 'warn',
  137. // 强制箭头函数的箭头前后使用一致的空格
  138. 'arrow-spacing': 'warn',
  139. 'prefer-const': 'warn', //指定常量
  140. // 必须使用 ...args 而不是 arguments
  141. // @off 没必要强制要求
  142. 'prefer-rest-params': 'warn',
  143. // 禁止出现没必要的转义
  144. // @off 转义可以使代码更易懂
  145. 'no-useless-escape': 'warn',
  146. // 禁止使用特殊空白符(比如全角空格),除非是出现在字符串、正则表达式或模版字符串中
  147. 'no-irregular-whitespace': 'warn',
  148. // 禁止使用 hasOwnProperty, isPrototypeOf 或 propertyIsEnumerable
  149. // @off hasOwnProperty 比较常用
  150. 'no-prototype-builtins': 'warn',
  151. // switch 的 case 内必须有 break, return 或 throw
  152. 'no-fallthrough': 'warn',
  153. // @fixable 禁止不必要的布尔类型转换,比如 !! 或 Boolean
  154. 'no-extra-boolean-cast': 'warn',
  155. // switch 的 case 内有变量定义的时候,必须使用大括号将 case 内变成一个代码块
  156. 'no-case-declarations': 'warn',
  157. 'no-async-promise-executor': 'warn',
  158. },
  159. globals: {
  160. defineProps: 'readonly',
  161. defineEmits: 'readonly',
  162. defineExpose: 'readonly',
  163. withDefaults: 'readonly',
  164. },
  165. }