.eslintrc.js 7.7 KB

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