.eslintrc.js 6.2 KB

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