.eslintrc.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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': [
  13. 'plugin:vue/recommended',
  14. 'eslint:recommended'
  15. ],
  16. overrides: [
  17. {
  18. files: [
  19. '**/__tests__/*.{j,t}s?(x)',
  20. '**/tests/unit/**/*.spec.{j,t}s?(x)'
  21. ],
  22. env: {
  23. jest: true
  24. }
  25. }
  26. ],
  27. // add your custom rules here
  28. // it is base on https://github.com/vuejs/eslint-config-vue
  29. rules: {
  30. 'vue/max-attributes-per-line': [2, {
  31. 'singleline': 10,
  32. 'multiline': {
  33. 'max': 1,
  34. 'allowFirstLine': false
  35. }
  36. }],
  37. 'vue/singleline-html-element-content-newline': 'off',
  38. 'vue/multiline-html-element-content-newline': 'off',
  39. 'vue/name-property-casing': ['error', 'kebab-case'], // |PascalCase
  40. 'vue/require-default-prop': 'off',
  41. 'vue/no-v-html': 'off',
  42. 'accessor-pairs': 2,
  43. 'arrow-spacing': [2, {
  44. 'before': true,
  45. 'after': true
  46. }],
  47. 'block-spacing': [2, 'always'],
  48. 'brace-style': [2, '1tbs', {
  49. 'allowSingleLine': true
  50. }],
  51. 'camelcase': [0, {
  52. 'properties': 'always'
  53. }],
  54. 'comma-dangle': [2, 'never'],
  55. 'comma-spacing': [2, {
  56. 'before': false,
  57. 'after': true
  58. }],
  59. 'comma-style': [2, 'last'],
  60. 'constructor-super': 2,
  61. 'curly': [2, 'multi-line'],
  62. 'dot-location': [2, 'property'],
  63. 'eol-last': 2,
  64. 'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
  65. 'generator-star-spacing': [2, {
  66. 'before': true,
  67. 'after': true
  68. }],
  69. 'handle-callback-err': [2, '^(err|error)$'],
  70. // 'indent': ["off", 2, {
  71. // 'SwitchCase': 1
  72. // }],
  73. "vue/script-indent": [
  74. 2,
  75. 4,
  76. {
  77. "baseIndent": 1,
  78. "switchCase": 1,
  79. "MemberExpression": 1
  80. }
  81. ],
  82. "vue/html-indent": [
  83. 2,
  84. 4,
  85. {
  86. "attribute": 1,
  87. "closeBracket": 0,
  88. "alignAttributesVertically": true
  89. }
  90. ],
  91. 'jsx-quotes': [2, 'prefer-single'],
  92. 'key-spacing': [2, {
  93. 'beforeColon': false,
  94. 'afterColon': true
  95. }],
  96. 'keyword-spacing': [2, {
  97. 'before': true,
  98. 'after': true
  99. }],
  100. 'new-cap': [2, {
  101. 'newIsCap': true,
  102. 'capIsNew': false
  103. }],
  104. 'new-parens': 2,
  105. 'no-array-constructor': 2,
  106. 'no-caller': 2,
  107. 'no-console': 'off',
  108. 'no-class-assign': 2,
  109. 'no-cond-assign': 2,
  110. 'no-const-assign': 2,
  111. 'no-control-regex': 0,
  112. 'no-delete-var': 2,
  113. 'no-dupe-args': 2,
  114. 'no-dupe-class-members': 2,
  115. 'no-dupe-keys': 2,
  116. 'no-duplicate-case': 2,
  117. 'no-empty-character-class': 2,
  118. 'no-empty-pattern': 2,
  119. 'no-eval': 2,
  120. 'no-ex-assign': 2,
  121. 'no-extend-native': 2,
  122. 'no-extra-bind': 2,
  123. 'no-extra-boolean-cast': 2,
  124. 'no-extra-parens': [2, 'functions'],
  125. 'no-fallthrough': 2,
  126. 'no-floating-decimal': 2,
  127. 'no-func-assign': 2,
  128. 'no-implied-eval': 2,
  129. 'no-inner-declarations': [2, 'functions'],
  130. 'no-invalid-regexp': 2,
  131. 'no-irregular-whitespace': 2,
  132. 'no-iterator': 2,
  133. 'no-label-var': 2,
  134. 'no-labels': [2, {
  135. 'allowLoop': false,
  136. 'allowSwitch': false
  137. }],
  138. 'no-lone-blocks': 2,
  139. 'no-mixed-spaces-and-tabs': 2,
  140. 'no-multi-spaces': 2,
  141. 'no-multi-str': 2,
  142. 'no-multiple-empty-lines': [2, {
  143. 'max': 1
  144. }],
  145. 'no-native-reassign': 2,
  146. 'no-negated-in-lhs': 2,
  147. 'no-new-object': 2,
  148. 'no-new-require': 2,
  149. 'no-new-symbol': 2,
  150. 'no-new-wrappers': 2,
  151. 'no-obj-calls': 2,
  152. 'no-octal': 2,
  153. 'no-octal-escape': 2,
  154. 'no-path-concat': 2,
  155. 'no-proto': 2,
  156. 'no-redeclare': 2,
  157. 'no-regex-spaces': 2,
  158. 'no-return-assign': [2, 'except-parens'],
  159. 'no-self-assign': 2,
  160. 'no-self-compare': 2,
  161. 'no-sequences': 2,
  162. 'no-shadow-restricted-names': 2,
  163. 'no-spaced-func': 2,
  164. 'no-sparse-arrays': 2,
  165. 'no-this-before-super': 2,
  166. 'no-throw-literal': 2,
  167. 'no-trailing-spaces': 2,
  168. 'no-undef': 2,
  169. 'no-undef-init': 2,
  170. 'no-unexpected-multiline': 2,
  171. 'no-unmodified-loop-condition': 2,
  172. 'no-unneeded-ternary': [2, {
  173. 'defaultAssignment': false
  174. }],
  175. 'no-unreachable': 2,
  176. 'no-unsafe-finally': 2,
  177. // 'no-unused-vars': [2, {
  178. // 'vars': 'all',
  179. // 'args': 'none'
  180. // }],
  181. // 当存在定义而未使用的组件时,关闭报错
  182. 'vue/no-unused-components': 'off',
  183. // 当存在定义而未使用的变量时,关闭报错
  184. 'no-unused-vars': 'off',
  185. 'no-useless-call': 2,
  186. 'no-useless-computed-key': 2,
  187. 'no-useless-constructor': 2,
  188. 'no-useless-escape': 0,
  189. 'no-whitespace-before-property': 2,
  190. 'no-with': 2,
  191. 'one-var': [2, {
  192. 'initialized': 'never'
  193. }],
  194. 'operator-linebreak': [2, 'after', {
  195. 'overrides': {
  196. '?': 'before',
  197. ':': 'before'
  198. }
  199. }],
  200. 'padded-blocks': [2, 'never'],
  201. 'quotes': [2, 'single', {
  202. 'avoidEscape': true,
  203. 'allowTemplateLiterals': true
  204. }],
  205. 'semi': [2, 'never'],
  206. 'semi-spacing': [2, {
  207. 'before': false,
  208. 'after': true
  209. }],
  210. 'space-before-blocks': [2, 'always'],
  211. 'space-before-function-paren': [2, 'never'],
  212. 'space-in-parens': [2, 'never'],
  213. 'space-infix-ops': 2,
  214. 'space-unary-ops': [2, {
  215. 'words': true,
  216. 'nonwords': false
  217. }],
  218. 'spaced-comment': [2, 'always', {
  219. 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
  220. }],
  221. 'template-curly-spacing': [2, 'never'],
  222. 'use-isnan': 2,
  223. 'valid-typeof': 2,
  224. 'wrap-iife': [2, 'any'],
  225. 'yield-star-spacing': [2, 'both'],
  226. 'yoda': [2, 'never'],
  227. 'prefer-const': 2,
  228. 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
  229. 'object-curly-spacing': [2, 'always', {
  230. objectsInObjects: false
  231. }],
  232. 'array-bracket-spacing': [2, 'never'],
  233. 'no-async-promise-executor': 'off',
  234. 'require-atomic-updates': 'off',
  235. 'no-prototype-builtins': 'off',
  236. 'no-irregular-whitespace': 'off'
  237. }
  238. }