.eslintrc.js 5.6 KB

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