You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
5.5 KiB

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