.eslintrc.js 7.8 KB

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