.eslintrc.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. module.exports = {
  2. root: true,
  3. env: {
  4. node: true
  5. },
  6. extends: ['plugin:vue/essential', 'eslint:recommended'],
  7. rules: {
  8. 'accessor-pairs': 2,
  9. 'arrow-spacing': [
  10. 2,
  11. {
  12. before: true,
  13. after: true
  14. }
  15. ],
  16. 'block-spacing': [2, 'always'],
  17. 'brace-style': [
  18. 2,
  19. '1tbs',
  20. {
  21. allowSingleLine: true
  22. }
  23. ],
  24. camelcase: [
  25. 0,
  26. {
  27. properties: 'always'
  28. }
  29. ],
  30. 'comma-dangle': [2, 'never'],
  31. 'comma-spacing': [
  32. 2,
  33. {
  34. before: false,
  35. after: true
  36. }
  37. ],
  38. 'comma-style': [2, 'last'],
  39. 'constructor-super': 2,
  40. curly: [2, 'multi-line'],
  41. 'dot-location': [2, 'property'],
  42. 'eol-last': 2,
  43. eqeqeq: [2, 'allow-null'],
  44. 'generator-star-spacing': [
  45. 2,
  46. {
  47. before: true,
  48. after: true
  49. }
  50. ],
  51. 'handle-callback-err': [2, '^(err|error)$'],
  52. indent: [
  53. 2,
  54. 2,
  55. {
  56. SwitchCase: 1
  57. }
  58. ],
  59. 'jsx-quotes': [2, 'prefer-single'],
  60. 'key-spacing': [
  61. 2,
  62. {
  63. beforeColon: false,
  64. afterColon: true
  65. }
  66. ],
  67. 'keyword-spacing': [
  68. 2,
  69. {
  70. before: true,
  71. after: true
  72. }
  73. ],
  74. 'new-cap': [
  75. 2,
  76. {
  77. newIsCap: true,
  78. capIsNew: false
  79. }
  80. ],
  81. 'new-parens': 2,
  82. 'no-array-constructor': 2,
  83. 'no-caller': 2,
  84. 'no-console': 'off',
  85. 'no-class-assign': 2,
  86. 'no-cond-assign': 2,
  87. 'no-const-assign': 2,
  88. 'no-control-regex': 2,
  89. 'no-delete-var': 2,
  90. 'no-dupe-args': 2,
  91. 'no-dupe-class-members': 2,
  92. 'no-dupe-keys': 2,
  93. 'no-duplicate-case': 2,
  94. 'no-empty-character-class': 2,
  95. 'no-empty-pattern': 2,
  96. 'no-eval': 2,
  97. 'no-ex-assign': 2,
  98. 'no-extend-native': 2,
  99. 'no-extra-bind': 2,
  100. 'no-extra-boolean-cast': 2,
  101. 'no-extra-parens': [2, 'functions'],
  102. 'no-fallthrough': 2,
  103. 'no-floating-decimal': 2,
  104. 'no-func-assign': 2,
  105. 'no-implied-eval': 2,
  106. 'no-inner-declarations': [2, 'functions'],
  107. 'no-invalid-regexp': 2,
  108. 'no-irregular-whitespace': 2,
  109. 'no-iterator': 2,
  110. 'no-label-var': 2,
  111. 'no-labels': [
  112. 2,
  113. {
  114. allowLoop: false,
  115. allowSwitch: false
  116. }
  117. ],
  118. 'no-lone-blocks': 2,
  119. 'no-mixed-spaces-and-tabs': 2,
  120. 'no-multi-spaces': 2,
  121. 'no-multi-str': 2,
  122. 'no-multiple-empty-lines': [
  123. 2,
  124. {
  125. max: 1
  126. }
  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': [
  156. 2,
  157. {
  158. defaultAssignment: false
  159. }
  160. ],
  161. 'no-unreachable': 2,
  162. 'no-unsafe-finally': 2,
  163. 'no-unused-vars': [
  164. 2,
  165. {
  166. vars: 'all',
  167. args: 'none'
  168. }
  169. ],
  170. 'no-useless-call': 2,
  171. 'no-useless-computed-key': 2,
  172. 'no-useless-constructor': 2,
  173. 'no-useless-escape': 0,
  174. 'no-whitespace-before-property': 2,
  175. 'no-with': 2,
  176. 'one-var': [
  177. 2,
  178. {
  179. initialized: 'never'
  180. }
  181. ],
  182. 'operator-linebreak': [
  183. 2,
  184. 'after',
  185. {
  186. overrides: {
  187. '?': 'before',
  188. ':': 'before'
  189. }
  190. }
  191. ],
  192. 'padded-blocks': [2, 'never'],
  193. quotes: [
  194. 2,
  195. 'single',
  196. {
  197. avoidEscape: true,
  198. allowTemplateLiterals: true
  199. }
  200. ],
  201. 'semi': [2, 'always'], // 语句强制分号结尾
  202. 'space-before-blocks': [2, 'always'],
  203. 'space-before-function-paren': [2, 'never'],
  204. 'space-in-parens': [2, 'never'],
  205. 'space-infix-ops': 2,
  206. 'space-unary-ops': [
  207. 2,
  208. {
  209. words: true,
  210. nonwords: false
  211. }
  212. ],
  213. 'spaced-comment': [
  214. 2,
  215. 'always',
  216. {
  217. markers: [
  218. 'global',
  219. 'globals',
  220. 'eslint',
  221. 'eslint-disable',
  222. '*package',
  223. '!',
  224. ','
  225. ]
  226. }
  227. ],
  228. 'template-curly-spacing': [2, 'never'],
  229. 'use-isnan': 2,
  230. 'valid-typeof': 2,
  231. 'wrap-iife': [2, 'any'],
  232. 'yield-star-spacing': [2, 'both'],
  233. yoda: [2, 'never'],
  234. 'prefer-const': 2,
  235. 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
  236. 'object-curly-spacing': [
  237. 2,
  238. 'always',
  239. {
  240. objectsInObjects: false
  241. }
  242. ],
  243. 'array-bracket-spacing': [2, 'never']
  244. },
  245. parserOptions: {
  246. parser: 'babel-eslint'
  247. }
  248. };