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.

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