.eslintrc.js 5.8 KB

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