8
0

.eslintrc.cjs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. 'vue/singleline-html-element-content-newline': 'off',
  49. 'sort-imports': [
  50. 'error',
  51. {
  52. ignoreCase: false,
  53. ignoreDeclarationSort: true,
  54. ignoreMemberSort: false,
  55. memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
  56. allowSeparatedGroups: false,
  57. },
  58. ],
  59. // typescript
  60. 'import/named': 'off',
  61. // Override JS
  62. 'no-useless-constructor': 'off',
  63. 'indent': 'off',
  64. 'no-invalid-this': 'off',
  65. 'no-redeclare': 'off',
  66. 'no-use-before-define': 'off',
  67. 'brace-style': 'error',
  68. 'comma-dangle': ['error', 'always-multiline'],
  69. 'object-curly-spacing': ['error', 'always'],
  70. 'space-before-blocks': ['error', 'always'],
  71. 'space-before-function-paren': [
  72. 'error',
  73. {
  74. anonymous: 'always',
  75. named: 'never',
  76. asyncArrow: 'always',
  77. },
  78. ],
  79. 'space-infix-ops': 'error',
  80. 'keyword-spacing': ['error', {
  81. before: true,
  82. after: true,
  83. }],
  84. 'comma-spacing': ['error', {
  85. before: false,
  86. after: true,
  87. }],
  88. 'no-extra-parens': ['error', 'functions'],
  89. 'no-dupe-class-members': 'error',
  90. 'no-loss-of-precision': 'error',
  91. 'lines-between-class-members': ['error', 'always', {
  92. exceptAfterSingleLine: true,
  93. }],
  94. // vue
  95. 'vue/html-indent': ['error', 4],
  96. 'vue/max-attributes-per-line': 'off',
  97. 'vue/no-v-html': 'off',
  98. 'vue/require-prop-types': 'off',
  99. 'vue/require-default-prop': 'off',
  100. 'vue/multi-word-component-names': 'off',
  101. 'vue/prefer-import-from-vue': 'off',
  102. 'vue/no-v-text-v-html-on-component': 'off',
  103. 'vue/no-dupe-keys': 'off',
  104. // reactivity transform
  105. 'vue/no-setup-props-destructure': 'off',
  106. 'vue/component-tags-order': ['error', {
  107. order: ['template', 'script', 'style'],
  108. }],
  109. 'vue/block-tag-newline': ['error', {
  110. singleline: 'always',
  111. multiline: 'always',
  112. }],
  113. 'vue/component-name-in-template-casing': ['error', 'PascalCase' || 'kebab-case'],
  114. 'vue/component-options-name-casing': ['error', 'PascalCase'],
  115. 'vue/custom-event-name-casing': ['error', 'camelCase'],
  116. 'vue/define-macros-order': ['error', {
  117. order: ['defineProps', 'defineEmits'],
  118. }],
  119. 'vue/html-comment-content-spacing': ['error', 'always', {
  120. exceptions: ['-'],
  121. }],
  122. 'vue/no-restricted-v-bind': ['error', '/^v-/'],
  123. 'vue/no-useless-v-bind': 'error',
  124. 'vue/no-unused-refs': 'error',
  125. 'vue/padding-line-between-blocks': ['error', 'always'],
  126. 'vue/prefer-separate-static-class': 'error',
  127. // extensions
  128. 'vue/array-bracket-spacing': ['error', 'never'],
  129. 'vue/arrow-spacing': ['error', {
  130. before: true,
  131. after: true,
  132. }],
  133. 'vue/block-spacing': ['error', 'always'],
  134. 'vue/brace-style': ['error', 'stroustrup', {
  135. allowSingleLine: true,
  136. }],
  137. 'vue/comma-dangle': ['error', 'always-multiline'],
  138. 'vue/comma-spacing': ['error', {
  139. before: false,
  140. after: true,
  141. }],
  142. 'vue/comma-style': ['error', 'last'],
  143. 'vue/dot-location': ['error', 'property'],
  144. 'vue/dot-notation': ['error', {
  145. allowKeywords: true,
  146. }],
  147. 'vue/eqeqeq': ['error', 'smart'],
  148. // 'vue/func-call-spacing': ['off', 'never'],
  149. 'vue/key-spacing': ['error', {
  150. beforeColon: false,
  151. afterColon: true,
  152. }],
  153. 'vue/keyword-spacing': ['error', {
  154. before: true,
  155. after: true,
  156. }],
  157. 'vue/no-constant-condition': 'warn',
  158. 'vue/no-empty-pattern': 'error',
  159. 'vue/no-extra-parens': ['error', 'functions'],
  160. 'vue/no-irregular-whitespace': 'error',
  161. 'vue/no-loss-of-precision': 'error',
  162. 'vue/no-restricted-syntax': ['error', 'DebuggerStatement', 'LabeledStatement', 'WithStatement'],
  163. 'vue/no-sparse-arrays': 'error',
  164. 'vue/object-curly-newline': ['error', {
  165. multiline: true,
  166. consistent: true,
  167. }],
  168. 'vue/object-curly-spacing': ['error', 'always'],
  169. 'vue/object-property-newline': ['error', {
  170. allowMultiplePropertiesPerLine: true,
  171. }],
  172. 'vue/object-shorthand': ['error', 'always', {
  173. ignoreConstructors: false,
  174. avoidQuotes: true,
  175. }],
  176. 'vue/operator-linebreak': ['error', 'before'],
  177. 'vue/prefer-template': 'error',
  178. 'vue/quote-props': ['error', 'consistent-as-needed'],
  179. 'vue/space-in-parens': ['error', 'never'],
  180. 'vue/space-infix-ops': 'error',
  181. 'vue/space-unary-ops': ['error', {
  182. words: true,
  183. nonwords: false,
  184. }],
  185. 'vue/template-curly-spacing': 'error',
  186. },
  187. }