.eslintrc.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
  15. // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
  16. 'plugin:vue/essential',
  17. // https://github.com/standard/standard/blob/master/docs/RULES-en.md
  18. 'standard'
  19. ],
  20. // add your custom rules here
  21. // it is base on https://github.com/vuejs/eslint-config-vue
  22. rules: {
  23. 'vue/singleline-html-element-content-newline': 'off',
  24. 'vue/multiline-html-element-content-newline': 'off',
  25. 'vue/name-property-casing': ['error', 'PascalCase'],
  26. 'vue/no-v-html': 'off',
  27. 'accessor-pairs': 2,
  28. 'arrow-spacing': [
  29. 2,
  30. {
  31. before: true,
  32. after: true
  33. }
  34. ],
  35. 'block-spacing': [2, 'always'],
  36. 'brace-style': [
  37. 2,
  38. '1tbs',
  39. {
  40. allowSingleLine: true
  41. }
  42. ],
  43. camelcase: [
  44. 0,
  45. {
  46. properties: 'always'
  47. }
  48. ],
  49. 'comma-dangle': ['error', 'never'],
  50. 'comma-spacing': [
  51. 2,
  52. {
  53. before: false,
  54. after: true
  55. }
  56. ],
  57. 'comma-style': [2, 'last'],
  58. 'constructor-super': 2,
  59. curly: [2, 'multi-line'],
  60. 'dot-location': [2, 'property'],
  61. 'eol-last': 2,
  62. eqeqeq: ['error', 'always', { null: 'ignore' }],
  63. 'generator-star-spacing': [
  64. 2,
  65. {
  66. before: true,
  67. after: true
  68. }
  69. ],
  70. 'handle-callback-err': [2, '^(err|error)$'],
  71. indent: [
  72. 2,
  73. 2,
  74. {
  75. SwitchCase: 1
  76. }
  77. ],
  78. 'jsx-quotes': [2, 'prefer-single'],
  79. 'key-spacing': [
  80. 2,
  81. {
  82. beforeColon: false,
  83. afterColon: true
  84. }
  85. ],
  86. 'keyword-spacing': [
  87. 2,
  88. {
  89. before: true,
  90. after: true
  91. }
  92. ],
  93. 'new-cap': [
  94. 2,
  95. {
  96. newIsCap: true,
  97. capIsNew: false
  98. }
  99. ],
  100. 'new-parens': 2,
  101. 'no-array-constructor': 2,
  102. 'no-caller': 2,
  103. 'no-console': 'off',
  104. 'no-class-assign': 2,
  105. 'no-cond-assign': 2,
  106. 'no-const-assign': 2,
  107. 'no-control-regex': 0,
  108. 'no-delete-var': 2,
  109. 'no-dupe-args': 2,
  110. 'no-dupe-class-members': 2,
  111. 'no-dupe-keys': 2,
  112. 'no-duplicate-case': 2,
  113. 'no-empty-character-class': 2,
  114. 'no-empty-pattern': 2,
  115. 'no-eval': 2,
  116. 'no-ex-assign': 2,
  117. 'no-extend-native': 2,
  118. 'no-extra-bind': 2,
  119. 'no-extra-boolean-cast': 2,
  120. 'no-extra-parens': [2, 'functions'],
  121. 'no-fallthrough': 2,
  122. 'no-floating-decimal': 2,
  123. 'no-func-assign': 2,
  124. 'no-implied-eval': 2,
  125. 'no-inner-declarations': [2, 'functions'],
  126. 'no-invalid-regexp': 2,
  127. 'no-irregular-whitespace': 2,
  128. 'no-iterator': 2,
  129. 'no-label-var': 2,
  130. 'no-labels': [
  131. 2,
  132. {
  133. allowLoop: false,
  134. allowSwitch: false
  135. }
  136. ],
  137. 'no-lone-blocks': 2,
  138. 'no-mixed-spaces-and-tabs': 2,
  139. 'no-multi-spaces': 2,
  140. 'no-multi-str': 2,
  141. 'no-multiple-empty-lines': [
  142. 2,
  143. {
  144. max: 1
  145. }
  146. ],
  147. 'no-native-reassign': 2,
  148. 'no-negated-in-lhs': 2,
  149. 'no-new-object': 2,
  150. 'no-new-require': 2,
  151. 'no-new-symbol': 2,
  152. 'no-new-wrappers': 2,
  153. 'no-obj-calls': 2,
  154. 'no-octal': 2,
  155. 'no-octal-escape': 2,
  156. 'no-path-concat': 2,
  157. 'no-proto': 2,
  158. 'no-redeclare': 2,
  159. 'no-regex-spaces': 2,
  160. 'no-return-assign': [2, 'except-parens'],
  161. 'no-self-assign': 2,
  162. 'no-self-compare': 2,
  163. 'no-sequences': 2,
  164. 'no-shadow-restricted-names': 2,
  165. 'no-spaced-func': 2,
  166. 'no-sparse-arrays': 2,
  167. 'no-this-before-super': 2,
  168. 'no-throw-literal': 2,
  169. 'no-trailing-spaces': 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': [
  175. 2,
  176. {
  177. defaultAssignment: false
  178. }
  179. ],
  180. 'no-unreachable': 2,
  181. 'no-unsafe-finally': 2,
  182. 'no-unused-vars': [
  183. 2,
  184. {
  185. vars: 'all',
  186. args: 'none'
  187. }
  188. ],
  189. 'no-useless-call': 2,
  190. 'no-useless-computed-key': 2,
  191. 'no-useless-constructor': 2,
  192. 'no-useless-escape': 0,
  193. 'no-whitespace-before-property': 2,
  194. 'no-with': 2,
  195. 'one-var': [
  196. 2,
  197. {
  198. initialized: 'never'
  199. }
  200. ],
  201. 'operator-linebreak': [
  202. 2,
  203. 'after',
  204. {
  205. overrides: {
  206. '?': 'before',
  207. ':': 'before'
  208. }
  209. }
  210. ],
  211. 'padded-blocks': [2, 'never'],
  212. quotes: [
  213. 2,
  214. 'single',
  215. {
  216. avoidEscape: true,
  217. allowTemplateLiterals: true
  218. }
  219. ],
  220. semi: [2, 'always'],
  221. 'semi-spacing': [
  222. 2,
  223. {
  224. before: false,
  225. after: true
  226. }
  227. ],
  228. 'space-before-blocks': [2, 'always'],
  229. 'space-before-function-paren': [2, 'never'],
  230. 'space-in-parens': [2, 'never'],
  231. 'space-infix-ops': 2,
  232. 'space-unary-ops': [
  233. 2,
  234. {
  235. words: true,
  236. nonwords: false
  237. }
  238. ],
  239. 'spaced-comment': [
  240. 2,
  241. 'always',
  242. {
  243. markers: [
  244. 'global',
  245. 'globals',
  246. 'eslint',
  247. 'eslint-disable',
  248. '*package',
  249. '!',
  250. ','
  251. ]
  252. }
  253. ],
  254. 'template-curly-spacing': [2, 'never'],
  255. 'use-isnan': 2,
  256. 'valid-typeof': 2,
  257. 'wrap-iife': [2, 'any'],
  258. 'yield-star-spacing': [2, 'both'],
  259. yoda: [2, 'never'],
  260. 'prefer-const': 2,
  261. 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
  262. 'object-curly-spacing': [
  263. 2,
  264. 'always',
  265. {
  266. objectsInObjects: false
  267. }
  268. ],
  269. 'array-bracket-spacing': [2, 'never']
  270. },
  271. globals: {
  272. AMap: 'writable',
  273. Amap: false
  274. }
  275. };