.eslintrc.js 6.2 KB

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