.eslintrc.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. module.exports = {
  2. root: true,
  3. env: {
  4. browser: true,
  5. node: true,
  6. es6: true
  7. },
  8. extends: [
  9. 'plugin:vue/recommended',
  10. 'eslint:recommended'
  11. ],
  12. parserOptions: {
  13. parser: 'babel-eslint',
  14. sourceType: 'module'
  15. },
  16. // eslint 规则 https://cloud.tencent.com/developer/chapter/12618
  17. // add your custom rules here
  18. // it is base on https://github.com/vuejs/eslint-config-vue
  19. rules: {
  20. 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  21. 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  22. 'vue/max-attributes-per-line': [2, {
  23. 'singleline': 5,
  24. 'multiline': {
  25. 'max': 1,
  26. 'allowFirstLine': false
  27. }
  28. }],
  29. 'vue/singleline-html-element-content-newline': 'off',
  30. 'vue/multiline-html-element-content-newline': 'off',
  31. 'vue/name-property-casing': ['error', 'PascalCase'],
  32. 'vue/no-v-html': 'off',
  33. 'accessor-pairs': 2,
  34. 'array-callback-return': 2, // 强制在数组方法(Array.from,Array.prototype.reduce等)的回调中使用语句
  35. 'array-bracket-newline': [2, {
  36. 'multiline': true
  37. }], // 在打开和关闭数组括号之前强制换行
  38. 'array-element-newline': [2, {
  39. 'multiline': true
  40. }], // 数组元素之间的换行符
  41. 'arrow-spacing': [2, {
  42. 'before': true,
  43. 'after': true
  44. }],
  45. 'arrow-parens': ['error', 'as-needed'],
  46. 'block-spacing': [2, 'always'],
  47. 'brace-style': [2, '1tbs', {
  48. 'allowSingleLine': true
  49. }],
  50. 'camelcase': [0, {
  51. 'properties': 'always'
  52. }],
  53. 'comma-dangle': [2, 'never'],
  54. 'comma-spacing': [2, {
  55. 'before': false,
  56. 'after': true
  57. }],
  58. 'comma-style': [2, 'last'],
  59. 'constructor-super': 2,
  60. 'curly': [2, 'multi-line'],
  61. 'dot-location': [2, 'property'],
  62. 'eol-last': 2,
  63. 'eqeqeq': ['error', 'always', {'null': 'ignore'}],
  64. 'generator-star-spacing': [2, {
  65. 'before': true,
  66. 'after': true
  67. }],
  68. 'handle-callback-err': [2, '^(err|error)$'],
  69. 'indent': [2, 2, {
  70. 'SwitchCase': 1
  71. }],
  72. 'jsx-quotes': [2, 'prefer-single'],
  73. 'key-spacing': [2, {
  74. 'beforeColon': false,
  75. 'afterColon': true
  76. }],
  77. 'keyword-spacing': [2, {
  78. 'before': true,
  79. 'after': true
  80. }],
  81. 'max-lines': [2, 1500],
  82. 'max-params': [2, 4], // 函数定义中允许的最大数量的参数
  83. 'max-statements': [2, 80], // 函数中允许的最大语句数
  84. 'new-cap': [2, {
  85. 'newIsCap': true,
  86. 'capIsNew': false
  87. }],
  88. 'new-parens': 2,
  89. 'no-array-constructor': 2,
  90. 'no-caller': 2,
  91. 'no-class-assign': 2,
  92. 'no-cond-assign': 2,
  93. 'no-const-assign': 2,
  94. 'no-control-regex': 0,
  95. 'no-delete-var': 2,
  96. 'no-dupe-args': 2,
  97. 'no-dupe-class-members': 2,
  98. 'no-dupe-keys': 2,
  99. 'no-duplicate-case': 2,
  100. 'no-empty-character-class': 2,
  101. 'no-empty-pattern': 2,
  102. 'no-eval': 2,
  103. 'no-ex-assign': 2,
  104. 'no-extend-native': 2,
  105. 'no-extra-bind': 2,
  106. 'no-extra-boolean-cast': 2,
  107. 'no-extra-parens': [2, 'functions'],
  108. 'no-fallthrough': 2,
  109. 'no-floating-decimal': 2,
  110. 'no-func-assign': 2,
  111. 'no-implied-eval': 2,
  112. 'no-inner-declarations': [2, 'functions'],
  113. 'no-invalid-regexp': 2,
  114. 'no-irregular-whitespace': 2,
  115. 'no-iterator': 2,
  116. 'no-label-var': 2,
  117. 'no-labels': [2, {
  118. 'allowLoop': false,
  119. 'allowSwitch': false
  120. }],
  121. 'no-lone-blocks': 2,
  122. 'no-mixed-spaces-and-tabs': 2,
  123. 'no-multi-spaces': 2,
  124. 'no-multi-str': 2,
  125. 'no-multiple-empty-lines': [2, {
  126. 'max': 1
  127. }],
  128. 'no-native-reassign': 2,
  129. 'no-negated-in-lhs': 2,
  130. 'no-new-object': 2,
  131. 'no-new-require': 2,
  132. 'no-new-symbol': 2,
  133. 'no-new-wrappers': 2,
  134. 'no-obj-calls': 2,
  135. 'no-octal': 2,
  136. 'no-octal-escape': 2,
  137. 'no-path-concat': 2,
  138. 'no-proto': 2,
  139. 'no-redeclare': 2,
  140. 'no-regex-spaces': 2,
  141. 'no-return-assign': [2, 'except-parens'],
  142. 'no-self-assign': 2,
  143. 'no-self-compare': 2,
  144. 'no-sequences': 2,
  145. 'no-shadow-restricted-names': 2,
  146. 'no-spaced-func': 2,
  147. 'no-sparse-arrays': 2,
  148. 'no-this-before-super': 2,
  149. 'no-throw-literal': 2,
  150. 'no-trailing-spaces': 2,
  151. 'no-undef': 2,
  152. 'no-undef-init': 2,
  153. 'no-unexpected-multiline': 2,
  154. 'no-unmodified-loop-condition': 2,
  155. 'no-unneeded-ternary': [2, {
  156. 'defaultAssignment': false
  157. }],
  158. 'no-unreachable': 2,
  159. 'no-unsafe-finally': 2,
  160. 'no-unused-vars': [2, {
  161. 'vars': 'all',
  162. 'args': 'none'
  163. }],
  164. 'no-useless-call': 2,
  165. 'no-useless-computed-key': 2,
  166. 'no-useless-constructor': 2,
  167. 'no-useless-escape': 0,
  168. 'no-whitespace-before-property': 2,
  169. 'no-with': 2,
  170. 'one-var': [2, {
  171. 'initialized': 'never'
  172. }],
  173. 'operator-linebreak': [2, 'after', {
  174. 'overrides': {
  175. '?': 'before',
  176. ':': 'before'
  177. }
  178. }],
  179. 'padded-blocks': [2, 'never'],
  180. 'quotes': [2, 'single', {
  181. 'avoidEscape': true,
  182. 'allowTemplateLiterals': true
  183. }],
  184. 'semi': [2, 'never'],
  185. 'semi-spacing': [2, {
  186. 'before': false,
  187. 'after': true
  188. }],
  189. 'space-before-blocks': [2, 'always'],
  190. 'space-before-function-paren': [2, 'never'],
  191. 'space-in-parens': [2, 'never'],
  192. 'space-infix-ops': 2,
  193. 'space-unary-ops': [2, {
  194. 'words': true,
  195. 'nonwords': false
  196. }],
  197. 'spaced-comment': [2, 'always', {
  198. 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
  199. }],
  200. 'template-curly-spacing': [2, 'never'],
  201. 'use-isnan': 2,
  202. 'valid-typeof': 2,
  203. 'wrap-iife': [2, 'any'],
  204. 'yield-star-spacing': [2, 'both'],
  205. 'yoda': [2, 'never'],
  206. 'prefer-const': 2,
  207. 'object-curly-spacing': [2, 'always', {
  208. objectsInObjects: false
  209. }],
  210. 'object-property-newline': [2, {
  211. allowAllPropertiesOnSameLine: true
  212. }],
  213. 'object-curly-newline': ['error', {
  214. 'ObjectExpression': {
  215. 'multiline': true,
  216. 'consistent': true
  217. },
  218. 'ObjectPattern': {'multiline': true}
  219. }],
  220. 'array-bracket-spacing': [2, 'never']
  221. }
  222. }