.eslintrc.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. // ESlint 检查配置
  2. module.exports = {
  3. root: true,
  4. parserOptions: {
  5. parser: 'babel-eslint',
  6. sourceType: 'module',
  7. },
  8. env: {
  9. browser: true,
  10. node: true,
  11. es6: true,
  12. },
  13. extends: [
  14. 'plugin:vue/recommended',
  15. 'eslint:recommended',
  16. ],
  17. // add your custom rules here
  18. //it is base on https://github.com/vuejs/eslint-config-vue
  19. rules: {
  20. 'vue/max-attributes-per-line': [
  21. 2,
  22. {
  23. singleline: 10,
  24. multiline: {
  25. max: 1,
  26. allowFirstLine: false,
  27. },
  28. },
  29. ],
  30. 'vue/singleline-html-element-content-newline': 'off',
  31. 'vue/multiline-html-element-content-newline': 'off',
  32. 'vue/name-property-casing': ['error', 'PascalCase'],
  33. 'vue/no-v-html': 'off',
  34. 'accessor-pairs': 2,
  35. 'arrow-spacing': [
  36. 2,
  37. {
  38. before: true,
  39. after: true,
  40. },
  41. ],
  42. 'block-spacing': [2, 'always'],
  43. 'brace-style': [
  44. 2,
  45. '1tbs',
  46. {
  47. allowSingleLine: true,
  48. },
  49. ],
  50. camelcase: [
  51. 0,
  52. {
  53. properties: 'always',
  54. },
  55. ],
  56. 'comma-dangle': [2, 'never'],
  57. 'comma-spacing': [
  58. 2,
  59. {
  60. before: false,
  61. after: true,
  62. },
  63. ],
  64. 'comma-style': [2, 'last'],
  65. 'constructor-super': 2,
  66. curly: [2, 'multi-line'],
  67. 'dot-location': [2, 'property'],
  68. 'eol-last': 2,
  69. eqeqeq: ['error', 'always', { null: 'ignore' }],
  70. 'generator-star-spacing': [
  71. 2,
  72. {
  73. before: true,
  74. after: true,
  75. },
  76. ],
  77. 'handle-callback-err': [2, '^(err|error)$'],
  78. indent: [
  79. 2,
  80. 2,
  81. {
  82. SwitchCase: 1,
  83. },
  84. ],
  85. 'jsx-quotes': [2, 'prefer-single'],
  86. 'key-spacing': [
  87. 2,
  88. {
  89. beforeColon: false,
  90. afterColon: true,
  91. },
  92. ],
  93. 'keyword-spacing': [
  94. 2,
  95. {
  96. before: true,
  97. after: true,
  98. },
  99. ],
  100. 'new-cap': [
  101. 2,
  102. {
  103. newIsCap: true,
  104. capIsNew: false,
  105. },
  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': [
  138. 2,
  139. {
  140. allowLoop: false,
  141. allowSwitch: false,
  142. },
  143. ],
  144. 'no-lone-blocks': 2,
  145. 'no-mixed-spaces-and-tabs': 2,
  146. 'no-multi-spaces': 2,
  147. 'no-multi-str': 2,
  148. 'no-multiple-empty-lines': [
  149. 2,
  150. {
  151. max: 1,
  152. },
  153. ],
  154. 'no-native-reassign': 2,
  155. 'no-negated-in-lhs': 2,
  156. 'no-new-object': 2,
  157. 'no-new-require': 2,
  158. 'no-new-symbol': 2,
  159. 'no-new-wrappers': 2,
  160. 'no-obj-calls': 2,
  161. 'no-octal': 2,
  162. 'no-octal-escape': 2,
  163. 'no-path-concat': 2,
  164. 'no-proto': 2,
  165. 'no-redeclare': 2,
  166. 'no-regex-spaces': 2,
  167. 'no-return-assign': [2, 'except-parens'],
  168. 'no-self-assign': 2,
  169. 'no-self-compare': 2,
  170. 'no-sequences': 2,
  171. 'no-shadow-restricted-names': 2,
  172. 'no-spaced-func': 2,
  173. 'no-sparse-arrays': 2,
  174. 'no-this-before-super': 2,
  175. 'no-throw-literal': 2,
  176. 'no-trailing-spaces': 2,
  177. 'no-undef': 2,
  178. 'no-undef-init': 2,
  179. 'no-unexpected-multiline': 2,
  180. 'no-unmodified-loop-condition': 2,
  181. 'no-unneeded-ternary': [
  182. 2,
  183. {
  184. defaultAssignment: false,
  185. },
  186. ],
  187. 'no-unreachable': 2,
  188. 'no-unsafe-finally': 2,
  189. 'no-unused-vars': [
  190. 2,
  191. {
  192. vars: 'all',
  193. args: 'none',
  194. },
  195. ],
  196. 'no-useless-call': 2,
  197. 'no-useless-computed-key': 2,
  198. 'no-useless-constructor': 2,
  199. 'no-useless-escape': 0,
  200. 'no-whitespace-before-property': 2,
  201. 'no-with': 2,
  202. 'one-var': [
  203. 2,
  204. {
  205. initialized: 'never',
  206. },
  207. ],
  208. 'operator-linebreak': [
  209. 2,
  210. 'after',
  211. {
  212. overrides: {
  213. '?': 'before',
  214. ':': 'before',
  215. },
  216. },
  217. ],
  218. 'padded-blocks': [2, 'never'],
  219. quotes: [
  220. 2,
  221. 'single',
  222. {
  223. avoidEscape: true,
  224. allowTemplateLiterals: true,
  225. },
  226. ],
  227. semi: [2, 'never'],
  228. 'semi-spacing': [
  229. 2,
  230. {
  231. before: false,
  232. after: true,
  233. },
  234. ],
  235. 'space-before-blocks': [2, 'always'],
  236. 'space-before-function-paren': [2, 'never'],
  237. 'space-in-parens': [2, 'never'],
  238. 'space-infix-ops': 2,
  239. 'space-unary-ops': [
  240. 2,
  241. {
  242. words: true,
  243. nonwords: false,
  244. },
  245. ],
  246. 'spaced-comment': [
  247. 2,
  248. 'always',
  249. {
  250. markers: [
  251. 'global',
  252. 'globals',
  253. 'eslint',
  254. 'eslint-disable',
  255. '*package',
  256. '!',
  257. ',',
  258. ],
  259. },
  260. ],
  261. 'template-curly-spacing': [2, 'never'],
  262. 'use-isnan': 2,
  263. 'valid-typeof': 2,
  264. 'wrap-iife': [2, 'any'],
  265. 'yield-star-spacing': [2, 'both'],
  266. yoda: [2, 'never'],
  267. 'prefer-const': 2,
  268. 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
  269. 'object-curly-spacing': [
  270. 2,
  271. 'always',
  272. {
  273. objectsInObjects: false,
  274. },
  275. ],
  276. 'array-bracket-spacing': [2, 'never'],
  277. },
  278. };