.eslintrc.cjs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* eslint-env node */
  2. module.exports = {
  3. root: true,
  4. env: {
  5. browser: true,
  6. es2021: true,
  7. node: true,
  8. },
  9. parser: "vue-eslint-parser",
  10. extends: [
  11. "plugin:vue/vue3-recommended",
  12. 'eslint:recommended',
  13. '@unocss'
  14. ],
  15. parserOptions: {
  16. ecmaVersion: "latest",
  17. sourceType: "module",
  18. },
  19. globals: {},
  20. plugins: ['vue'],
  21. rules: {
  22. // Common
  23. 'semi': ['error', 'never'],
  24. 'curly': 'off',
  25. 'quotes': ['error', 'single'],
  26. 'quote-props': ['error', 'consistent-as-needed'],
  27. 'no-console': 'off',
  28. // best-practice
  29. 'array-callback-return': 'error',
  30. 'block-scoped-var': 'error',
  31. 'consistent-return': 'off',
  32. 'complexity': 'off',
  33. 'eqeqeq': ['error', 'smart'],
  34. 'no-alert': 'warn',
  35. 'no-case-declarations': 'error',
  36. 'no-multi-spaces': 'error',
  37. 'no-multi-str': 'error',
  38. 'no-with': 'error',
  39. 'no-void': 'error',
  40. 'no-useless-escape': 'off',
  41. 'vars-on-top': 'error',
  42. 'require-await': 'off',
  43. 'no-return-assign': 'off',
  44. 'operator-linebreak': ['error', 'before'],
  45. 'max-statements-per-line': ['error', {
  46. max: 1
  47. }],
  48. 'sort-imports': [
  49. 'error',
  50. {
  51. ignoreCase: false,
  52. ignoreDeclarationSort: true,
  53. ignoreMemberSort: false,
  54. memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
  55. allowSeparatedGroups: false,
  56. },
  57. ],
  58. // typescript
  59. 'import/named': 'off',
  60. // Override JS
  61. 'no-useless-constructor': 'off',
  62. 'indent': 'off',
  63. 'no-invalid-this': 'off',
  64. 'no-redeclare': 'off',
  65. "no-use-before-define": 'off',
  66. 'brace-style': 'error',
  67. 'comma-dangle': ['error', 'always-multiline'],
  68. 'object-curly-spacing': ['error', 'always'],
  69. 'space-before-blocks': ['error', 'always'],
  70. 'space-before-function-paren': [
  71. 'error',
  72. {
  73. anonymous: 'always',
  74. named: 'never',
  75. asyncArrow: 'always',
  76. },
  77. ],
  78. 'space-infix-ops': 'error',
  79. 'keyword-spacing': ['error', {
  80. before: true,
  81. after: true
  82. }],
  83. 'comma-spacing': ['error', {
  84. before: false,
  85. after: true
  86. }],
  87. 'no-extra-parens': ['error', 'functions'],
  88. 'no-dupe-class-members': 'error',
  89. 'no-loss-of-precision': 'error',
  90. 'lines-between-class-members': ['error', 'always', {
  91. exceptAfterSingleLine: true
  92. }],
  93. // vue
  94. "vue/html-indent": ["error", 4],
  95. 'vue/max-attributes-per-line': 'off',
  96. 'vue/no-v-html': 'off',
  97. 'vue/require-prop-types': 'off',
  98. 'vue/require-default-prop': 'off',
  99. 'vue/multi-word-component-names': 'off',
  100. 'vue/prefer-import-from-vue': 'off',
  101. 'vue/no-v-text-v-html-on-component': 'off',
  102. 'vue/no-dupe-keys': 'off',
  103. 'vue/no-use-v-if-with-v-for': 'off',
  104. 'vue/singleline-html-element-content-newline': 'off',
  105. // reactivity transform
  106. 'vue/no-setup-props-destructure': 'off',
  107. 'vue/component-tags-order': ['error', {
  108. order: ['template', 'script', 'style'],
  109. }],
  110. 'vue/block-tag-newline': ['error', {
  111. singleline: 'always',
  112. multiline: 'always',
  113. }],
  114. 'vue/component-name-in-template-casing': ['error', 'PascalCase' || 'kebab-case'],
  115. 'vue/component-options-name-casing': ['error', 'PascalCase'],
  116. 'vue/custom-event-name-casing': ['error', 'camelCase'],
  117. 'vue/define-macros-order': ['error', {
  118. order: ['defineProps', 'defineEmits'],
  119. }],
  120. 'vue/html-comment-content-spacing': ['error', 'always', {
  121. exceptions: ['-'],
  122. }],
  123. 'vue/no-restricted-v-bind': ['error', '/^v-/'],
  124. 'vue/no-useless-v-bind': 'error',
  125. 'vue/no-unused-refs': 'error',
  126. 'vue/padding-line-between-blocks': ['error', 'always'],
  127. 'vue/prefer-separate-static-class': 'error',
  128. // extensions
  129. 'vue/array-bracket-spacing': ['error', 'never'],
  130. 'vue/arrow-spacing': ['error', {
  131. before: true,
  132. after: true
  133. }],
  134. 'vue/block-spacing': ['error', 'always'],
  135. 'vue/brace-style': ['error', 'stroustrup', {
  136. allowSingleLine: true
  137. }],
  138. 'vue/comma-dangle': ['error', 'always-multiline'],
  139. 'vue/comma-spacing': ['error', {
  140. before: false,
  141. after: true
  142. }],
  143. 'vue/comma-style': ['error', 'last'],
  144. 'vue/dot-location': ['error', 'property'],
  145. 'vue/dot-notation': ['error', {
  146. allowKeywords: true
  147. }],
  148. 'vue/eqeqeq': ['error', 'smart'],
  149. // 'vue/func-call-spacing': ['off', 'never'],
  150. 'vue/key-spacing': ['error', {
  151. beforeColon: false,
  152. afterColon: true
  153. }],
  154. 'vue/keyword-spacing': ['error', {
  155. before: true,
  156. after: true
  157. }],
  158. 'vue/no-constant-condition': 'warn',
  159. 'vue/no-empty-pattern': 'error',
  160. 'vue/no-extra-parens': ['error', 'functions'],
  161. 'vue/no-irregular-whitespace': 'error',
  162. 'vue/no-loss-of-precision': 'error',
  163. 'vue/no-restricted-syntax': ['error', 'DebuggerStatement', 'LabeledStatement', 'WithStatement'],
  164. 'vue/no-sparse-arrays': 'error',
  165. 'vue/object-curly-newline': ['error', {
  166. multiline: true,
  167. consistent: true
  168. }],
  169. 'vue/object-curly-spacing': ['error', 'always'],
  170. 'vue/object-property-newline': ['error', {
  171. allowMultiplePropertiesPerLine: true
  172. }],
  173. 'vue/object-shorthand': ['error', 'always', {
  174. ignoreConstructors: false,
  175. avoidQuotes: true,
  176. }],
  177. 'vue/operator-linebreak': ['error', 'before'],
  178. 'vue/prefer-template': 'error',
  179. 'vue/quote-props': ['error', 'consistent-as-needed'],
  180. 'vue/space-in-parens': ['error', 'never'],
  181. 'vue/space-infix-ops': 'error',
  182. 'vue/space-unary-ops': ['error', {
  183. words: true,
  184. nonwords: false
  185. }],
  186. 'vue/template-curly-spacing': 'error',
  187. },
  188. };