.eslintrc.js 5.1 KB

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