.eslintrc.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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: ['plugin:vue/recommended', 'eslint:recommended'],
  14. // add your custom rules here
  15. //it is base on https://github.com/vuejs/eslint-config-vue
  16. rules: {
  17. "vue/max-attributes-per-line": [2, {
  18. "singleline": 10,
  19. "multiline": {
  20. "max": 1,
  21. "allowFirstLine": false
  22. }
  23. }],
  24. "vue/html-self-closing": ["error",{
  25. "html": {
  26. "void": "never",
  27. "normal": "any",
  28. "component": "any"
  29. },
  30. "svg": "always",
  31. "math": "always"
  32. }],
  33. "vue/singleline-html-element-content-newline": "off",
  34. "vue/multiline-html-element-content-newline":"off",
  35. "vue/name-property-casing": ["error", "PascalCase"],
  36. "vue/no-v-html": "off",
  37. 'accessor-pairs': 2,
  38. 'arrow-spacing': [2, {
  39. 'before': true,
  40. 'after': true
  41. }],
  42. 'block-spacing': [2, 'always'],
  43. 'brace-style': [2, '1tbs', {
  44. 'allowSingleLine': true
  45. }],
  46. 'camelcase': [0, {
  47. 'properties': 'always'
  48. }],
  49. 'comma-dangle': [2, 'never'],
  50. 'comma-spacing': [2, {
  51. 'before': false,
  52. 'after': true
  53. }],
  54. 'comma-style': [2, 'last'],
  55. 'constructor-super': 2,
  56. 'curly': [2, 'multi-line'],
  57. 'dot-location': [2, 'property'],
  58. 'eol-last': 2,
  59. 'eqeqeq': ["error", "always", {"null": "ignore"}],
  60. 'generator-star-spacing': [2, {
  61. 'before': true,
  62. 'after': true
  63. }],
  64. 'handle-callback-err': [2, '^(err|error)$'],
  65. 'indent': [2, 2, {
  66. 'SwitchCase': 1
  67. }],
  68. 'jsx-quotes': [2, 'prefer-single'],
  69. 'key-spacing': [2, {
  70. 'beforeColon': false,
  71. 'afterColon': true
  72. }],
  73. 'keyword-spacing': [2, {
  74. 'before': true,
  75. 'after': true
  76. }],
  77. 'new-cap': [2, {
  78. 'newIsCap': true,
  79. 'capIsNew': false
  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': 0,
  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': [2, {
  112. 'allowLoop': false,
  113. 'allowSwitch': false
  114. }],
  115. 'no-lone-blocks': 2,
  116. 'no-mixed-spaces-and-tabs': 2,
  117. 'no-multi-spaces': 2,
  118. 'no-multi-str': 2,
  119. 'no-multiple-empty-lines': [2, {
  120. 'max': 1
  121. }],
  122. 'no-native-reassign': 2,
  123. 'no-negated-in-lhs': 2,
  124. 'no-new-object': 2,
  125. 'no-new-require': 2,
  126. 'no-new-symbol': 2,
  127. 'no-new-wrappers': 2,
  128. 'no-obj-calls': 2,
  129. 'no-octal': 2,
  130. 'no-octal-escape': 2,
  131. 'no-path-concat': 2,
  132. 'no-proto': 2,
  133. 'no-redeclare': 2,
  134. 'no-regex-spaces': 2,
  135. 'no-return-assign': [2, 'except-parens'],
  136. 'no-self-assign': 2,
  137. 'no-self-compare': 2,
  138. 'no-sequences': 2,
  139. 'no-shadow-restricted-names': 2,
  140. 'no-spaced-func': 2,
  141. 'no-sparse-arrays': 2,
  142. 'no-this-before-super': 2,
  143. 'no-throw-literal': 2,
  144. 'no-trailing-spaces': 2,
  145. 'no-undef': 2,
  146. 'no-undef-init': 2,
  147. 'no-unexpected-multiline': 2,
  148. 'no-unmodified-loop-condition': 2,
  149. 'no-unneeded-ternary': [2, {
  150. 'defaultAssignment': false
  151. }],
  152. 'no-unreachable': 2,
  153. 'no-unsafe-finally': 2,
  154. 'no-unused-vars': [2, {
  155. 'vars': 'all',
  156. 'args': 'none'
  157. }],
  158. 'no-useless-call': 2,
  159. 'no-useless-computed-key': 2,
  160. 'no-useless-constructor': 2,
  161. 'no-useless-escape': 0,
  162. 'no-whitespace-before-property': 2,
  163. 'no-with': 2,
  164. 'one-var': [2, {
  165. 'initialized': 'never'
  166. }],
  167. 'operator-linebreak': [2, 'after', {
  168. 'overrides': {
  169. '?': 'before',
  170. ':': 'before'
  171. }
  172. }],
  173. 'padded-blocks': [2, 'never'],
  174. 'quotes': [2, 'single', {
  175. 'avoidEscape': true,
  176. 'allowTemplateLiterals': true
  177. }],
  178. 'semi': [2, 'never'],
  179. 'semi-spacing': [2, {
  180. 'before': false,
  181. 'after': true
  182. }],
  183. 'space-before-blocks': [2, 'always'],
  184. 'space-before-function-paren': [2, 'always'],
  185. 'space-in-parens': [2, 'never'],
  186. 'space-infix-ops': 0,
  187. 'space-unary-ops': [2, {
  188. 'words': true,
  189. 'nonwords': false
  190. }],
  191. 'spaced-comment': [2, 'always', {
  192. 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
  193. }],
  194. 'template-curly-spacing': [2, 'never'],
  195. 'use-isnan': 2,
  196. 'valid-typeof': 2,
  197. 'wrap-iife': [2, 'any'],
  198. 'yield-star-spacing': [2, 'both'],
  199. 'yoda': [2, 'never'],
  200. 'prefer-const': 2,
  201. 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
  202. 'object-curly-spacing': [2, 'never', {
  203. objectsInObjects: false,
  204. arraysInObjects: false
  205. }],
  206. 'array-bracket-spacing': [2, 'never']
  207. }
  208. }