.eslintrc.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. // ESlint 检查配置
  2. module.exports = {
  3. root: true,
  4. parserOptions: {
  5. parser: "babel-eslint",
  6. sourceType: "module",
  7. },
  8. env: {
  9. browser: true,
  10. node: true,
  11. es6: true,
  12. },
  13. extends: ["plugin:vue/recommended", "eslint:recommended"],
  14. // add your custom rules here
  15. //it is base on https://github.com/vuejs/eslint-config-vue
  16. rules: {
  17. "vue/max-attributes-per-line": [
  18. 2,
  19. {
  20. singleline: 10,
  21. multiline: {
  22. max: 1,
  23. allowFirstLine: false,
  24. },
  25. },
  26. ],
  27. "vue/singleline-html-element-content-newline": "off",
  28. "vue/multiline-html-element-content-newline": "off",
  29. "vue/name-property-casing": ["error", "PascalCase"],
  30. "vue/no-v-html": "off",
  31. "accessor-pairs": 2,
  32. "arrow-spacing": [
  33. 2,
  34. {
  35. before: true,
  36. after: true,
  37. },
  38. ],
  39. "block-spacing": [2, "always"],
  40. "brace-style": [
  41. 2,
  42. "1tbs",
  43. {
  44. allowSingleLine: true,
  45. },
  46. ],
  47. camelcase: [
  48. 0,
  49. {
  50. properties: "always",
  51. },
  52. ],
  53. "comma-dangle": [2, "never"],
  54. "comma-spacing": [
  55. 2,
  56. {
  57. before: false,
  58. after: true,
  59. },
  60. ],
  61. "comma-style": [2, "last"],
  62. "constructor-super": 2,
  63. curly: [2, "multi-line"],
  64. "dot-location": [2, "property"],
  65. "eol-last": 2,
  66. eqeqeq: ["error", "always", { null: "ignore" }],
  67. "generator-star-spacing": [
  68. 2,
  69. {
  70. before: true,
  71. after: true,
  72. },
  73. ],
  74. "handle-callback-err": [2, "^(err|error)$"],
  75. indent: [
  76. 2,
  77. 2,
  78. {
  79. SwitchCase: 1,
  80. },
  81. ],
  82. "jsx-quotes": [2, "prefer-single"],
  83. "key-spacing": [
  84. 2,
  85. {
  86. beforeColon: false,
  87. afterColon: true,
  88. },
  89. ],
  90. "keyword-spacing": [
  91. 2,
  92. {
  93. before: true,
  94. after: true,
  95. },
  96. ],
  97. "new-cap": [
  98. 2,
  99. {
  100. newIsCap: true,
  101. capIsNew: false,
  102. },
  103. ],
  104. "new-parens": 2,
  105. "no-array-constructor": 2,
  106. "no-caller": 2,
  107. "no-console": "off",
  108. "no-class-assign": 2,
  109. "no-cond-assign": 2,
  110. "no-const-assign": 2,
  111. "no-control-regex": 0,
  112. "no-delete-var": 2,
  113. "no-dupe-args": 2,
  114. "no-dupe-class-members": 2,
  115. "no-dupe-keys": 2,
  116. "no-duplicate-case": 2,
  117. "no-empty-character-class": 2,
  118. "no-empty-pattern": 2,
  119. "no-eval": 2,
  120. "no-ex-assign": 2,
  121. "no-extend-native": 2,
  122. "no-extra-bind": 2,
  123. "no-extra-boolean-cast": 2,
  124. "no-extra-parens": [2, "functions"],
  125. "no-fallthrough": 2,
  126. "no-floating-decimal": 2,
  127. "no-func-assign": 2,
  128. "no-implied-eval": 2,
  129. "no-inner-declarations": [2, "functions"],
  130. "no-invalid-regexp": 2,
  131. "no-irregular-whitespace": 2,
  132. "no-iterator": 2,
  133. "no-label-var": 2,
  134. "no-labels": [
  135. 2,
  136. {
  137. allowLoop: false,
  138. allowSwitch: false,
  139. },
  140. ],
  141. "no-lone-blocks": 2,
  142. "no-mixed-spaces-and-tabs": 2,
  143. "no-multi-spaces": 2,
  144. "no-multi-str": 2,
  145. "no-multiple-empty-lines": [
  146. 2,
  147. {
  148. max: 1,
  149. },
  150. ],
  151. "no-native-reassign": 2,
  152. "no-negated-in-lhs": 2,
  153. "no-new-object": 2,
  154. "no-new-require": 2,
  155. "no-new-symbol": 2,
  156. "no-new-wrappers": 2,
  157. "no-obj-calls": 2,
  158. "no-octal": 2,
  159. "no-octal-escape": 2,
  160. "no-path-concat": 2,
  161. "no-proto": 2,
  162. "no-redeclare": 2,
  163. "no-regex-spaces": 2,
  164. "no-return-assign": [2, "except-parens"],
  165. "no-self-assign": 2,
  166. "no-self-compare": 2,
  167. "no-sequences": 2,
  168. "no-shadow-restricted-names": 2,
  169. "no-spaced-func": 2,
  170. "no-sparse-arrays": 2,
  171. "no-this-before-super": 2,
  172. "no-throw-literal": 2,
  173. "no-trailing-spaces": 2,
  174. "no-undef": 2,
  175. "no-undef-init": 2,
  176. "no-unexpected-multiline": 2,
  177. "no-unmodified-loop-condition": 2,
  178. "no-unneeded-ternary": [
  179. 2,
  180. {
  181. defaultAssignment: false,
  182. },
  183. ],
  184. "no-unreachable": 2,
  185. "no-unsafe-finally": 2,
  186. "no-unused-vars": [
  187. 2,
  188. {
  189. vars: "all",
  190. args: "none",
  191. },
  192. ],
  193. "no-useless-call": 2,
  194. "no-useless-computed-key": 2,
  195. "no-useless-constructor": 2,
  196. "no-useless-escape": 0,
  197. "no-whitespace-before-property": 2,
  198. "no-with": 2,
  199. "one-var": [
  200. 2,
  201. {
  202. initialized: "never",
  203. },
  204. ],
  205. "operator-linebreak": [
  206. 2,
  207. "after",
  208. {
  209. overrides: {
  210. "?": "before",
  211. ":": "before",
  212. },
  213. },
  214. ],
  215. "padded-blocks": [2, "never"],
  216. quotes: [
  217. 2,
  218. "single",
  219. {
  220. avoidEscape: true,
  221. allowTemplateLiterals: true,
  222. },
  223. ],
  224. semi: [2, "never"],
  225. "semi-spacing": [
  226. 2,
  227. {
  228. before: false,
  229. after: true,
  230. },
  231. ],
  232. "space-before-blocks": [2, "always"],
  233. "space-before-function-paren": [2, "never"],
  234. "space-in-parens": [2, "never"],
  235. "space-infix-ops": 2,
  236. "space-unary-ops": [
  237. 2,
  238. {
  239. words: true,
  240. nonwords: false,
  241. },
  242. ],
  243. "spaced-comment": [
  244. 2,
  245. "always",
  246. {
  247. markers: [
  248. "global",
  249. "globals",
  250. "eslint",
  251. "eslint-disable",
  252. "*package",
  253. "!",
  254. ",",
  255. ],
  256. },
  257. ],
  258. "template-curly-spacing": [2, "never"],
  259. "use-isnan": 2,
  260. "valid-typeof": 2,
  261. "wrap-iife": [2, "any"],
  262. "yield-star-spacing": [2, "both"],
  263. yoda: [2, "never"],
  264. "prefer-const": 2,
  265. "no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
  266. "object-curly-spacing": [
  267. 2,
  268. "always",
  269. {
  270. objectsInObjects: false,
  271. },
  272. ],
  273. "array-bracket-spacing": [2, "never"],
  274. },
  275. };