.eslintrc.js 6.8 KB

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