.eslintrc.js 5.8 KB

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