.eslintrc.cjs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. module.exports = {
  2. 'env': {
  3. 'browser': true,
  4. 'es2021': true,
  5. 'node': true
  6. },
  7. 'extends': [
  8. 'plugin:vue/recommended', 'eslint:recommended'
  9. ],
  10. 'overrides': [
  11. ],
  12. globals: {
  13. 'uni': null,
  14. 'ElMessage': null,
  15. 'ElMessageBox': null
  16. },
  17. 'parserOptions': {
  18. 'ecmaVersion': 'latest',
  19. 'sourceType': 'module'
  20. },
  21. 'plugins': [
  22. 'vue'
  23. ],
  24. 'rules': {
  25. 'vue/multi-word-component-names': 'off',
  26. 'vue/max-attributes-per-line': [2, {
  27. 'singleline': 10,
  28. 'multiline': {
  29. 'max': 1
  30. }
  31. }],
  32. 'vue/no-v-model-argument': 'off',
  33. 'vue/singleline-html-element-content-newline': 'off',
  34. 'vue/multiline-html-element-content-newline': 'off',
  35. 'vue/name-property-casing': 'off',
  36. 'vue/no-v-html': 'off',
  37. 'vue/html-self-closing': [
  38. 1,
  39. {
  40. html: {
  41. void: 'always',
  42. normal: 'never',
  43. component: 'always',
  44. },
  45. svg: 'always',
  46. math: 'always',
  47. },
  48. ],
  49. 'indent': [2, 2], // 缩进2个空格
  50. // "semi": [2, 1], // 禁用行尾使用分号
  51. 'no-trailing-spaces': [1, {
  52. 'skipBlankLines': false, // false 禁止在空行使用空白符
  53. 'ignoreComments': true, // true 允许在注释块中使用空白符
  54. }], // 一行结束后面不要有空格
  55. 'no-unused-vars': [
  56. 1,
  57. {
  58. argsIgnorePattern: '^_',
  59. varsIgnorePattern: '^_',
  60. },
  61. ], // 未使用声明
  62. 'space-before-function-paren': [2, {
  63. 'anonymous': 'always', // 匿名函数
  64. 'named': 'always', // 命名函数
  65. 'asyncArrow': 'always' // 异步函数
  66. }],
  67. 'accessor-pairs': 2,
  68. 'arrow-spacing': [2, {
  69. 'before': true,
  70. 'after': true
  71. }],
  72. 'block-spacing': [2, 'always'],
  73. 'brace-style': [2, '1tbs', {
  74. 'allowSingleLine': true
  75. }],
  76. 'camelcase': [0, {
  77. 'properties': 'always'
  78. }],
  79. 'comma-dangle': [0, 'never'],
  80. 'comma-spacing': [2, {
  81. 'before': false,
  82. 'after': true
  83. }],
  84. 'comma-style': [2, 'last'],
  85. 'constructor-super': 2,
  86. 'curly': [2, 'multi-line'],
  87. 'dot-location': [2, 'property'],
  88. 'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
  89. 'generator-star-spacing': [2, {
  90. 'before': true,
  91. 'after': true
  92. }],
  93. 'handle-callback-err': [2, '^(err|error)$'],
  94. 'jsx-quotes': [2, 'prefer-single'],
  95. 'key-spacing': [2, {
  96. 'beforeColon': false,
  97. 'afterColon': true
  98. }],
  99. 'keyword-spacing': [2, {
  100. 'before': true,
  101. 'after': true
  102. }],
  103. 'new-cap': [2, {
  104. 'newIsCap': true,
  105. 'capIsNew': false
  106. }],
  107. 'new-parens': 2,
  108. 'no-array-constructor': 2,
  109. 'no-caller': 2,
  110. 'no-console': 'off',
  111. 'no-class-assign': 2,
  112. 'no-cond-assign': 2,
  113. 'no-const-assign': 2,
  114. 'no-control-regex': 0,
  115. 'no-delete-var': 2,
  116. 'no-dupe-args': 2,
  117. 'no-dupe-class-members': 2,
  118. 'no-dupe-keys': 2,
  119. 'no-duplicate-case': 2,
  120. 'no-empty-character-class': 2,
  121. 'no-empty-pattern': 2,
  122. 'no-eval': 2,
  123. 'no-ex-assign': 2,
  124. 'no-extend-native': 2,
  125. 'no-extra-bind': 2,
  126. 'no-extra-boolean-cast': 2,
  127. 'no-extra-parens': [2, 'functions'],
  128. 'no-fallthrough': 2,
  129. 'no-floating-decimal': 2,
  130. 'no-func-assign': 2,
  131. 'no-implied-eval': 2,
  132. 'no-inner-declarations': [2, 'functions'],
  133. 'no-invalid-regexp': 2,
  134. 'no-irregular-whitespace': 2,
  135. 'no-iterator': 2,
  136. 'no-label-var': 2,
  137. 'no-labels': [2, {
  138. 'allowLoop': false,
  139. 'allowSwitch': false
  140. }],
  141. 'no-lone-blocks': 2,
  142. 'no-mixed-spaces-and-tabs': 2,
  143. 'no-multi-spaces': 2,
  144. 'no-multi-str': 2,
  145. 'no-multiple-empty-lines': [1, {
  146. 'max': 1
  147. }],
  148. 'no-native-reassign': 2,
  149. 'no-negated-in-lhs': 2,
  150. 'no-new-object': 2,
  151. 'no-new-require': 2,
  152. 'no-new-symbol': 2,
  153. 'no-new-wrappers': 2,
  154. 'no-obj-calls': 2,
  155. 'no-octal': 2,
  156. 'no-octal-escape': 2,
  157. 'no-path-concat': 2,
  158. 'no-proto': 2,
  159. 'no-redeclare': 2,
  160. 'no-regex-spaces': 2,
  161. 'no-return-assign': [2, 'except-parens'],
  162. 'no-self-assign': 2,
  163. 'no-self-compare': 2,
  164. 'no-sequences': 2,
  165. 'no-shadow-restricted-names': 2,
  166. 'no-spaced-func': 2,
  167. 'no-sparse-arrays': 2,
  168. 'no-this-before-super': 2,
  169. 'no-throw-literal': 2,
  170. 'no-undef': 2,
  171. 'no-undef-init': 2,
  172. 'no-unexpected-multiline': 2,
  173. 'no-unmodified-loop-condition': 2,
  174. 'no-unneeded-ternary': [2, {
  175. 'defaultAssignment': false
  176. }],
  177. 'no-unreachable': 2,
  178. 'no-unsafe-finally': 2,
  179. 'no-useless-call': 2,
  180. 'no-useless-computed-key': 2,
  181. 'no-useless-constructor': 2,
  182. 'no-useless-escape': 0,
  183. 'no-whitespace-before-property': 2,
  184. 'no-with': 2,
  185. 'one-var': [2, {
  186. 'initialized': 'never'
  187. }],
  188. 'operator-linebreak': [2, 'after', {
  189. 'overrides': {
  190. '?': 'before',
  191. ':': 'before'
  192. }
  193. }],
  194. 'padded-blocks': [2, 'never'],
  195. 'quotes': [2, 'single', {
  196. 'avoidEscape': true,
  197. 'allowTemplateLiterals': true
  198. }],
  199. 'semi': [0, 'never'],
  200. 'semi-spacing': [2, {
  201. 'before': false,
  202. 'after': true
  203. }],
  204. 'space-before-blocks': [2, 'always'],
  205. 'space-in-parens': [2, 'never'],
  206. 'space-infix-ops': 2,
  207. 'space-unary-ops': [2, {
  208. 'words': true,
  209. 'nonwords': false
  210. }],
  211. 'spaced-comment': [2, 'always', {
  212. 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
  213. }],
  214. 'template-curly-spacing': [2, 'never'],
  215. 'use-isnan': 2,
  216. 'valid-typeof': 2,
  217. 'wrap-iife': [2, 'any'],
  218. 'yield-star-spacing': [2, 'both'],
  219. 'yoda': [2, 'never'],
  220. 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
  221. 'object-curly-spacing': [2, 'always', {
  222. objectsInObjects: false
  223. }],
  224. 'array-bracket-spacing': [2, 'never'],
  225. 'vue/no-v-for-template-key': 'off'
  226. }
  227. }