.eslintrc.js 7.8 KB

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