.eslintrc.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. module.exports = {
  2. root: true,
  3. env: {
  4. node: true,
  5. browser: true,
  6. es6: true
  7. },
  8. extends: ['plugin:vue/strongly-recommended', 'eslint:recommended', '@vue/prettier'],
  9. parserOptions: {
  10. parser: 'babel-eslint'
  11. },
  12. rules: {
  13. 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  14. 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  15. 'prettier/prettier': [
  16. 'error',
  17. {
  18. tabWidth: 2,
  19. useTabs: false,
  20. semi: true,
  21. singleQuote: true,
  22. trailingComma: 'none',
  23. endOfLine: 'auto',
  24. bracketSpacing: true,
  25. arrowParens: 'avoid',
  26. printWidth: 100
  27. }
  28. ],
  29. 'no-alert': 0,
  30. 'no-array-constructor': 2,
  31. 'no-bitwise': 0,
  32. 'no-caller': 1,
  33. 'no-catch-shadow': 2,
  34. 'no-class-assign': 2,
  35. 'no-cond-assign': 2,
  36. 'no-const-assign': 2,
  37. 'no-constant-condition': 2,
  38. 'no-continue': 0,
  39. 'no-control-regex': 2,
  40. 'no-delete-var': 2,
  41. 'no-div-regex': 1,
  42. 'no-dupe-keys': 2,
  43. 'no-dupe-args': 2,
  44. 'no-duplicate-case': 2,
  45. 'no-else-return': 2,
  46. 'no-empty': 2,
  47. 'no-empty-character-class': 2,
  48. 'no-empty-label': 0,
  49. 'no-eq-null': 2,
  50. 'no-eval': 1,
  51. 'no-ex-assign': 2,
  52. 'no-extend-native': 2,
  53. 'no-extra-bind': 2,
  54. 'no-extra-boolean-cast': 2,
  55. 'no-extra-parens': 2,
  56. 'no-extra-semi': 2,
  57. 'no-fallthrough': 1,
  58. 'no-floating-decimal': 2,
  59. 'no-func-assign': 2,
  60. 'no-implicit-coercion': 1,
  61. 'no-implied-eval': 2,
  62. 'no-inline-comments': 0,
  63. 'no-inner-declarations': [2, 'functions'],
  64. 'no-invalid-regexp': 2,
  65. 'no-invalid-this': 2,
  66. 'no-irregular-whitespace': 2,
  67. 'no-iterator': 2,
  68. 'no-label-var': 2,
  69. 'no-labels': 2,
  70. 'no-lone-blocks': 2,
  71. 'no-lonely-if': 2,
  72. 'no-loop-func': 1,
  73. 'no-mixed-requires': [0, false],
  74. 'no-mixed-spaces-and-tabs': [2, false],
  75. 'linebreak-style': [0, 'windows'],
  76. 'no-multi-spaces': 1,
  77. 'no-multi-str': 2,
  78. 'no-multiple-empty-lines': [
  79. 1,
  80. {
  81. max: 2
  82. }
  83. ],
  84. 'no-native-reassign': 2,
  85. 'no-negated-in-lhs': 2,
  86. 'no-nested-ternary': 0,
  87. 'no-new': 1,
  88. 'no-new-func': 1,
  89. 'no-new-object': 2,
  90. 'no-new-require': 2,
  91. 'no-new-wrappers': 2,
  92. 'no-obj-calls': 2,
  93. 'no-octal': 2,
  94. 'no-octal-escape': 2,
  95. 'no-param-reassign': 2,
  96. 'no-path-concat': 0,
  97. 'no-plusplus': 0,
  98. 'no-process-env': 0,
  99. 'no-process-exit': 0,
  100. 'no-proto': 2,
  101. 'no-redeclare': 2,
  102. 'no-regex-spaces': 2,
  103. 'no-restricted-modules': 0,
  104. 'no-return-assign': 1,
  105. 'no-script-url': 0,
  106. 'no-self-compare': 2,
  107. 'no-sequences': 0,
  108. 'no-shadow-restricted-names': 2,
  109. 'no-spaced-func': 2,
  110. 'no-sparse-arrays': 2,
  111. 'no-sync': 0,
  112. 'no-ternary': 0,
  113. 'no-trailing-spaces': 1,
  114. 'no-this-before-super': 0,
  115. 'no-throw-literal': 2,
  116. 'no-undef': 1,
  117. 'no-undef-init': 2,
  118. 'no-undefined': 2,
  119. 'no-unexpected-multiline': 2,
  120. 'no-underscore-dangle': 1,
  121. 'no-unneeded-ternary': 2,
  122. 'no-unreachable': 2,
  123. 'no-unused-vars': [
  124. 2,
  125. {
  126. vars: 'all',
  127. args: 'after-used'
  128. }
  129. ],
  130. 'no-use-before-define': 2,
  131. 'no-useless-call': 2,
  132. 'no-void': 2,
  133. 'no-var': 0,
  134. 'no-warning-comments': [
  135. 1,
  136. {
  137. terms: ['todo', 'fixme', 'xxx'],
  138. location: 'start'
  139. }
  140. ],
  141. 'no-with': 2,
  142. 'array-bracket-spacing': [2, 'never'],
  143. 'arrow-parens': 0,
  144. 'arrow-spacing': 0,
  145. 'accessor-pairs': 0,
  146. 'block-scoped-var': 0,
  147. 'brace-style': [1, '1tbs'],
  148. camelcase: 0,
  149. 'comma-dangle': [2, 'never'],
  150. 'comma-spacing': 0,
  151. 'comma-style': [2, 'last'],
  152. complexity: [0, 11],
  153. 'computed-property-spacing': [0, 'never'],
  154. 'consistent-return': 0,
  155. 'consistent-this': [2, 'that'],
  156. 'constructor-super': 0,
  157. curly: [2, 'all'],
  158. 'default-case': 0,
  159. 'dot-location': 0,
  160. 'dot-notation': [
  161. 0,
  162. {
  163. allowKeywords: true
  164. }
  165. ],
  166. 'eol-last': 0,
  167. eqeqeq: 2,
  168. 'func-names': 0,
  169. 'func-style': [0, 'declaration'],
  170. 'generator-star-spacing': 0,
  171. 'guard-for-in': 0,
  172. 'handle-callback-err': 0,
  173. 'id-length': 0,
  174. indent: [2, 2],
  175. 'init-declarations': 0,
  176. 'key-spacing': [
  177. 0,
  178. {
  179. beforeColon: false,
  180. afterColon: true
  181. }
  182. ],
  183. 'lines-around-comment': 0,
  184. 'max-depth': [0, 4],
  185. 'max-len': [0, 100, 4],
  186. 'max-nested-callbacks': [0, 2],
  187. 'max-params': [0, 3],
  188. 'max-statements': [0, 10],
  189. 'jsx-quotes': [2, 'prefer-single'],
  190. 'keyword-spacing': [
  191. 2,
  192. {
  193. before: true,
  194. after: true
  195. }
  196. ],
  197. 'new-cap': [
  198. 2,
  199. {
  200. newIsCap: true,
  201. capIsNew: false
  202. }
  203. ],
  204. 'new-parens': 2,
  205. 'object-curly-spacing': [0, 'never'],
  206. 'object-shorthand': 0,
  207. 'one-var': 0,
  208. 'operator-assignment': [0, 'always'],
  209. 'operator-linebreak': [
  210. 2,
  211. 'after',
  212. {
  213. overrides: {
  214. '?': 'before',
  215. ':': 'before'
  216. }
  217. }
  218. ],
  219. 'padded-blocks': 0,
  220. 'prefer-const': 0,
  221. 'prefer-spread': 0,
  222. 'prefer-reflect': 0,
  223. quotes: [1, 'single'],
  224. 'quote-props': [0, 'always'],
  225. radix: 2,
  226. 'id-match': 0,
  227. 'require-yield': 0,
  228. semi: [0, 'always'],
  229. 'semi-spacing': [
  230. 0,
  231. {
  232. before: false,
  233. after: true
  234. }
  235. ],
  236. 'sort-vars': 0,
  237. 'space-after-keywords': [0, 'always'],
  238. 'space-before-blocks': [0, 'always'],
  239. 'space-before-function-paren': [0, 'always'],
  240. 'space-in-parens': [0, 'never'],
  241. 'space-infix-ops': 0,
  242. 'space-return-throw-case': 0,
  243. 'space-unary-ops': [
  244. 0,
  245. {
  246. words: true,
  247. nonwords: false
  248. }
  249. ],
  250. 'spaced-comment': 0,
  251. strict: 2,
  252. 'use-isnan': 2,
  253. 'valid-jsdoc': 0,
  254. 'valid-typeof': 2,
  255. 'vars-on-top': 2,
  256. 'wrap-iife': [2, 'inside'],
  257. 'wrap-regex': 0,
  258. yoda: [2, 'never']
  259. },
  260. // jest 测试配置
  261. overrides: [
  262. {
  263. files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
  264. env: {
  265. jest: true
  266. }
  267. }
  268. ]
  269. };