.eslintrc.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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: 120
  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. curly: [2, 'multi-line'],
  86. 'dot-location': [2, 'property'],
  87. 'eol-last': 2,
  88. eqeqeq: [1, 'always'],
  89. 'generator-star-spacing': [
  90. 2,
  91. {
  92. before: false,
  93. after: true
  94. }
  95. ],
  96. indent: [
  97. 2,
  98. 2,
  99. {
  100. SwitchCase: 1
  101. }
  102. ],
  103. 'jsx-quotes': [2, 'prefer-single'],
  104. 'key-spacing': [
  105. 2,
  106. {
  107. beforeColon: false,
  108. afterColon: true
  109. }
  110. ],
  111. 'keyword-spacing': [
  112. 2,
  113. {
  114. before: true,
  115. after: true
  116. }
  117. ],
  118. 'new-cap': [
  119. 2,
  120. {
  121. newIsCap: true,
  122. capIsNew: false
  123. }
  124. ],
  125. 'no-caller': 2,
  126. 'no-eval': 2,
  127. 'no-labels': [
  128. 2,
  129. {
  130. allowLoop: false,
  131. allowSwitch: false
  132. }
  133. ],
  134. 'no-multi-spaces': 2,
  135. 'no-multiple-empty-lines': [
  136. 2,
  137. {
  138. max: 1
  139. }
  140. ],
  141. 'no-return-assign': [2, 'except-parens'],
  142. 'no-sequences': 2,
  143. 'no-trailing-spaces': 2,
  144. 'no-unmodified-loop-condition': 2,
  145. 'no-unneeded-ternary': [
  146. 2,
  147. {
  148. defaultAssignment: false
  149. }
  150. ],
  151. 'no-unused-vars': [
  152. 1,
  153. {
  154. vars: 'all',
  155. args: 'none'
  156. }
  157. ],
  158. 'no-useless-computed-key': 2,
  159. 'no-useless-constructor': 2,
  160. 'no-whitespace-before-property': 2,
  161. 'one-var': [
  162. 2,
  163. {
  164. initialized: 'never'
  165. }
  166. ],
  167. 'operator-linebreak': [
  168. 2,
  169. 'after',
  170. {
  171. overrides: {
  172. '?': 'before',
  173. ':': 'before'
  174. }
  175. }
  176. ],
  177. 'padded-blocks': [2, 'never'],
  178. quotes: [
  179. 2,
  180. 'single',
  181. {
  182. avoidEscape: true,
  183. allowTemplateLiterals: true
  184. }
  185. ],
  186. semi: [2, 'always'],
  187. 'semi-spacing': [
  188. 2,
  189. {
  190. before: false,
  191. after: true
  192. }
  193. ],
  194. 'space-before-blocks': [2, 'always'],
  195. 'space-in-parens': [2, 'never'],
  196. 'space-infix-ops': 2,
  197. 'space-unary-ops': [
  198. 2,
  199. {
  200. words: true,
  201. nonwords: false
  202. }
  203. ],
  204. 'spaced-comment': [
  205. 2,
  206. 'always',
  207. {
  208. markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
  209. }
  210. ],
  211. 'template-curly-spacing': [2, 'never'],
  212. 'wrap-iife': [2, 'any'],
  213. 'yield-star-spacing': [2, 'both'],
  214. 'object-curly-spacing': [
  215. 2,
  216. 'always',
  217. {
  218. objectsInObjects: false
  219. }
  220. ],
  221. 'no-alert': process.env.NODE_ENV === 'production' ? 1 : 0,
  222. 'no-array-constructor': 2,
  223. 'no-bitwise': 1,
  224. 'no-div-regex': 1,
  225. 'no-else-return': 2,
  226. 'no-empty': 1,
  227. 'no-eq-null': 2,
  228. 'no-extend-native': 2,
  229. 'no-extra-bind': 2,
  230. 'no-extra-parens': [2, 'functions'],
  231. 'no-floating-decimal': 2,
  232. 'no-implicit-coercion': 1,
  233. 'no-implied-eval': 2,
  234. 'no-inline-comments': 0,
  235. 'no-invalid-this': 2,
  236. 'no-iterator': 2,
  237. 'no-label-var': 2,
  238. 'no-lone-blocks': 2,
  239. 'no-lonely-if': 2,
  240. 'no-loop-func': 1,
  241. 'linebreak-style': [0, 'windows'],
  242. 'no-multi-str': 2,
  243. 'no-nested-ternary': 0,
  244. 'no-new': 1,
  245. 'no-new-func': 1,
  246. 'no-new-object': 2,
  247. 'no-new-wrappers': 2,
  248. 'no-octal-escape': 2,
  249. 'no-param-reassign': 2,
  250. 'no-plusplus': [1, { allowForLoopAfterthoughts: true }],
  251. 'no-proto': 2,
  252. 'no-self-compare': 2,
  253. 'func-call-spacing': 2,
  254. 'no-ternary': 0,
  255. 'no-throw-literal': 2,
  256. 'no-undef-init': 2,
  257. 'no-underscore-dangle': 1,
  258. 'no-use-before-define': 2,
  259. 'no-useless-call': 2,
  260. 'no-void': 2,
  261. 'no-var': 2,
  262. 'no-warning-comments': [
  263. 1,
  264. {
  265. terms: ['todo', 'fixme', 'xxx'],
  266. location: 'start'
  267. }
  268. ],
  269. 'array-bracket-spacing': [2, 'never'],
  270. 'arrow-parens': [1, 'as-needed'],
  271. 'computed-property-spacing': [1, 'never'],
  272. 'consistent-return': 0,
  273. 'default-case': 1,
  274. 'dot-notation': [
  275. 0,
  276. {
  277. allowKeywords: true
  278. }
  279. ],
  280. 'func-names': 1,
  281. 'func-style': [0, 'declaration'],
  282. 'guard-for-in': 0,
  283. 'id-length': 0,
  284. 'init-declarations': 1,
  285. 'lines-around-comment': 0,
  286. 'max-depth': [1, 4],
  287. 'max-len': [1, { code: 120, ignoreUrls: true, ignoreTemplateLiterals: true, ignoreRegExpLiterals: true }],
  288. 'max-nested-callbacks': 1,
  289. 'max-params': [1, 6],
  290. 'max-statements': [1, 40],
  291. 'new-parens': 2,
  292. 'object-shorthand': 1,
  293. 'operator-assignment': 1,
  294. 'prefer-spread': 1,
  295. 'quote-props': [1, 'as-needed'],
  296. radix: [1, 'as-needed'],
  297. 'id-match': 0,
  298. 'sort-vars': [1, { ignoreCase: true }],
  299. strict: 2,
  300. 'vars-on-top': 2,
  301. 'wrap-regex': 0,
  302. yoda: [2, 'never']
  303. },
  304. // jest 测试配置
  305. overrides: [
  306. {
  307. files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
  308. env: {
  309. jest: true
  310. }
  311. }
  312. ]
  313. };