.eslintrc.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. module.exports = {
  2. root: true,
  3. parserOptions: {
  4. parser: 'babel-eslint',
  5. sourceType: 'module'
  6. },
  7. env: {
  8. node: true,
  9. browser: true,
  10. es6: true
  11. },
  12. extends: ['plugin:vue/strongly-recommended', 'eslint:recommended', '@vue/prettier'],
  13. rules: {
  14. 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  15. 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  16. 'prettier/prettier': [
  17. 'error',
  18. {
  19. tabWidth: 2,
  20. useTabs: false,
  21. semi: true,
  22. singleQuote: true,
  23. trailingComma: 'none',
  24. endOfLine: 'auto',
  25. bracketSpacing: true,
  26. arrowParens: 'avoid',
  27. printWidth: 100
  28. }
  29. ],
  30. 'vue/max-attributes-per-line': [
  31. 2,
  32. {
  33. singleline: 10,
  34. multiline: {
  35. max: 1,
  36. allowFirstLine: false
  37. }
  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. 'no-caller': 2,
  118. 'no-control-regex': 0,
  119. 'no-dupe-class-members': 2,
  120. 'no-empty-pattern': 2,
  121. 'no-eval': 2,
  122. 'no-fallthrough': 2,
  123. 'no-labels': [
  124. 2,
  125. {
  126. allowLoop: false,
  127. allowSwitch: false
  128. }
  129. ],
  130. 'no-mixed-spaces-and-tabs': 2,
  131. 'no-multi-spaces': 2,
  132. 'no-multiple-empty-lines': [
  133. 2,
  134. {
  135. max: 1
  136. }
  137. ],
  138. 'no-new-symbol': 2,
  139. 'no-path-concat': 2,
  140. 'no-return-assign': [2, 'except-parens'],
  141. 'no-self-assign': 2,
  142. 'no-sequences': 2,
  143. 'no-this-before-super': 2,
  144. 'no-trailing-spaces': 2,
  145. 'no-unmodified-loop-condition': 2,
  146. 'no-unneeded-ternary': [
  147. 2,
  148. {
  149. defaultAssignment: false
  150. }
  151. ],
  152. 'no-unsafe-finally': 2,
  153. 'no-unused-vars': [
  154. 2,
  155. {
  156. vars: 'all',
  157. args: 'none'
  158. }
  159. ],
  160. 'no-useless-computed-key': 2,
  161. 'no-useless-constructor': 2,
  162. 'no-useless-escape': 0,
  163. 'no-whitespace-before-property': 2,
  164. 'one-var': [
  165. 2,
  166. {
  167. initialized: 'never'
  168. }
  169. ],
  170. 'operator-linebreak': [
  171. 2,
  172. 'after',
  173. {
  174. overrides: {
  175. '?': 'before',
  176. ':': 'before'
  177. }
  178. }
  179. ],
  180. 'padded-blocks': [2, 'never'],
  181. quotes: [
  182. 2,
  183. 'single',
  184. {
  185. avoidEscape: true,
  186. allowTemplateLiterals: true
  187. }
  188. ],
  189. semi: [0, 'never'],
  190. 'semi-spacing': [
  191. 2,
  192. {
  193. before: false,
  194. after: true
  195. }
  196. ],
  197. 'space-before-blocks': [2, 'always'],
  198. 'space-in-parens': [2, 'never'],
  199. 'space-infix-ops': 2,
  200. 'space-unary-ops': [
  201. 2,
  202. {
  203. words: true,
  204. nonwords: false
  205. }
  206. ],
  207. 'spaced-comment': [
  208. 2,
  209. 'always',
  210. {
  211. markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
  212. }
  213. ],
  214. 'template-curly-spacing': [2, 'never'],
  215. 'use-isnan': 2,
  216. 'valid-typeof': 2,
  217. 'wrap-iife': [2, 'any'],
  218. 'yield-star-spacing': [2, 'both'],
  219. 'object-curly-spacing': [
  220. 2,
  221. 'always',
  222. {
  223. objectsInObjects: false
  224. }
  225. ],
  226. 'no-alert': 0,
  227. 'no-array-constructor': 2,
  228. 'no-bitwise': 0,
  229. 'no-catch-shadow': 2,
  230. 'no-class-assign': 2,
  231. 'no-cond-assign': 2,
  232. 'no-const-assign': 2,
  233. 'no-constant-condition': 2,
  234. 'no-continue': 0,
  235. 'no-delete-var': 2,
  236. 'no-div-regex': 1,
  237. 'no-dupe-keys': 2,
  238. 'no-dupe-args': 2,
  239. 'no-duplicate-case': 2,
  240. 'no-else-return': 2,
  241. 'no-empty': 2,
  242. 'no-empty-character-class': 2,
  243. 'no-empty-label': 0,
  244. 'no-eq-null': 2,
  245. 'no-ex-assign': 2,
  246. 'no-extend-native': 2,
  247. 'no-extra-bind': 2,
  248. 'no-extra-boolean-cast': 2,
  249. 'no-extra-parens': [2, 'functions'],
  250. 'no-extra-semi': 2,
  251. 'no-floating-decimal': 2,
  252. 'no-func-assign': 2,
  253. 'no-implicit-coercion': 1,
  254. 'no-implied-eval': 2,
  255. 'no-inline-comments': 0,
  256. 'no-inner-declarations': [2, 'functions'],
  257. 'no-invalid-regexp': 2,
  258. 'no-invalid-this': 2,
  259. 'no-irregular-whitespace': 2,
  260. 'no-iterator': 2,
  261. 'no-label-var': 2,
  262. 'no-lone-blocks': 2,
  263. 'no-lonely-if': 2,
  264. 'no-loop-func': 1,
  265. 'no-mixed-requires': [0, false],
  266. 'linebreak-style': [0, 'windows'],
  267. 'no-multi-str': 2,
  268. 'no-native-reassign': 2,
  269. 'no-negated-in-lhs': 2,
  270. 'no-nested-ternary': 0,
  271. 'no-new': 1,
  272. 'no-new-func': 1,
  273. 'no-new-object': 2,
  274. 'no-new-require': 2,
  275. 'no-new-wrappers': 2,
  276. 'no-obj-calls': 2,
  277. 'no-octal': 2,
  278. 'no-octal-escape': 2,
  279. 'no-param-reassign': 2,
  280. 'no-plusplus': 0,
  281. 'no-process-env': 0,
  282. 'no-process-exit': 0,
  283. 'no-proto': 2,
  284. 'no-redeclare': 2,
  285. 'no-regex-spaces': 2,
  286. 'no-restricted-modules': 0,
  287. 'no-script-url': 0,
  288. 'no-self-compare': 2,
  289. 'no-shadow-restricted-names': 2,
  290. 'no-spaced-func': 2,
  291. 'no-sparse-arrays': 2,
  292. 'no-sync': 0,
  293. 'no-ternary': 0,
  294. 'no-throw-literal': 2,
  295. 'no-undef': 2,
  296. 'no-undef-init': 2,
  297. 'no-unexpected-multiline': 2,
  298. 'no-underscore-dangle': 1,
  299. 'no-unreachable': 2,
  300. 'no-use-before-define': 2,
  301. 'no-useless-call': 2,
  302. 'no-void': 2,
  303. 'no-var': 0,
  304. 'no-warning-comments': [
  305. 1,
  306. {
  307. terms: ['todo', 'fixme', 'xxx'],
  308. location: 'start'
  309. }
  310. ],
  311. 'no-with': 2,
  312. 'array-bracket-spacing': [2, 'never'],
  313. 'arrow-parens': 0,
  314. 'block-scoped-var': 0,
  315. 'computed-property-spacing': [0, 'never'],
  316. 'consistent-return': 0,
  317. 'consistent-this': [2, 'that'],
  318. 'default-case': 0,
  319. 'dot-notation': [
  320. 0,
  321. {
  322. allowKeywords: true
  323. }
  324. ],
  325. 'func-names': 0,
  326. 'func-style': [0, 'declaration'],
  327. 'guard-for-in': 0,
  328. 'id-length': 0,
  329. 'init-declarations': 0,
  330. 'lines-around-comment': 0,
  331. 'max-depth': [0, 4],
  332. 'max-len': [0, 100, 4],
  333. 'max-nested-callbacks': [0, 2],
  334. 'max-params': [0, 3],
  335. 'max-statements': [0, 10],
  336. 'new-parens': 2,
  337. 'object-shorthand': 0,
  338. 'operator-assignment': [0, 'always'],
  339. 'prefer-spread': 0,
  340. 'prefer-reflect': 0,
  341. 'quote-props': [0, 'always'],
  342. radix: 2,
  343. 'id-match': 0,
  344. 'require-yield': 0,
  345. 'sort-vars': 0,
  346. 'space-after-keywords': [0, 'always'],
  347. 'space-return-throw-case': 0,
  348. strict: 2,
  349. 'valid-jsdoc': 0,
  350. 'vars-on-top': 2,
  351. 'wrap-regex': 0,
  352. yoda: [2, 'never']
  353. },
  354. // jest 测试配置
  355. overrides: [
  356. {
  357. files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
  358. env: {
  359. jest: true
  360. }
  361. }
  362. ]
  363. };