.eslintrc.js 5.1 KB

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