.eslintrc.cjs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. ],
  14. parserOptions: {
  15. ecmaVersion: "latest",
  16. sourceType: "module",
  17. },
  18. globals: {},
  19. plugins: ['vue'],
  20. rules: {
  21. // Common
  22. 'semi': ['error', 'never'],
  23. 'curly': 'off',
  24. 'quotes': ['error', 'single'],
  25. 'quote-props': ['error', 'consistent-as-needed'],
  26. 'no-console': 'off',
  27. // best-practice
  28. 'array-callback-return': 'error',
  29. 'block-scoped-var': 'error',
  30. 'consistent-return': 'off',
  31. 'complexity': 'off',
  32. 'eqeqeq': ['error', 'smart'],
  33. 'no-alert': 'warn',
  34. 'no-case-declarations': 'error',
  35. 'no-multi-spaces': 'error',
  36. 'no-multi-str': 'error',
  37. 'no-with': 'error',
  38. 'no-void': 'error',
  39. 'no-useless-escape': 'off',
  40. 'vars-on-top': 'error',
  41. 'require-await': 'off',
  42. 'no-return-assign': 'off',
  43. 'operator-linebreak': ['error', 'before'],
  44. 'max-statements-per-line': ['error', {
  45. max: 1
  46. }],
  47. 'vue/singleline-html-element-content-newline': 'off',
  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. // reactivity transform
  104. 'vue/no-setup-props-destructure': 'off',
  105. 'vue/component-tags-order': ['error', {
  106. order: ['template', 'script', 'style'],
  107. }],
  108. 'vue/block-tag-newline': ['error', {
  109. singleline: 'always',
  110. multiline: 'always',
  111. }],
  112. 'vue/component-name-in-template-casing': ['error', 'PascalCase' || 'kebab-case'],
  113. 'vue/component-options-name-casing': ['error', 'PascalCase'],
  114. 'vue/custom-event-name-casing': ['error', 'camelCase'],
  115. 'vue/define-macros-order': ['error', {
  116. order: ['defineProps', 'defineEmits'],
  117. }],
  118. 'vue/html-comment-content-spacing': ['error', 'always', {
  119. exceptions: ['-'],
  120. }],
  121. 'vue/no-restricted-v-bind': ['error', '/^v-/'],
  122. 'vue/no-useless-v-bind': 'error',
  123. 'vue/no-unused-refs': 'error',
  124. 'vue/padding-line-between-blocks': ['error', 'always'],
  125. 'vue/prefer-separate-static-class': 'error',
  126. // extensions
  127. 'vue/array-bracket-spacing': ['error', 'never'],
  128. 'vue/arrow-spacing': ['error', {
  129. before: true,
  130. after: true
  131. }],
  132. 'vue/block-spacing': ['error', 'always'],
  133. 'vue/brace-style': ['error', 'stroustrup', {
  134. allowSingleLine: true
  135. }],
  136. 'vue/comma-dangle': ['error', 'always-multiline'],
  137. 'vue/comma-spacing': ['error', {
  138. before: false,
  139. after: true
  140. }],
  141. 'vue/comma-style': ['error', 'last'],
  142. 'vue/dot-location': ['error', 'property'],
  143. 'vue/dot-notation': ['error', {
  144. allowKeywords: true
  145. }],
  146. 'vue/eqeqeq': ['error', 'smart'],
  147. // 'vue/func-call-spacing': ['off', 'never'],
  148. 'vue/key-spacing': ['error', {
  149. beforeColon: false,
  150. afterColon: true
  151. }],
  152. 'vue/keyword-spacing': ['error', {
  153. before: true,
  154. after: true
  155. }],
  156. 'vue/no-constant-condition': 'warn',
  157. 'vue/no-empty-pattern': 'error',
  158. 'vue/no-extra-parens': ['error', 'functions'],
  159. 'vue/no-irregular-whitespace': 'error',
  160. 'vue/no-loss-of-precision': 'error',
  161. 'vue/no-restricted-syntax': ['error', 'DebuggerStatement', 'LabeledStatement', 'WithStatement'],
  162. 'vue/no-sparse-arrays': 'error',
  163. 'vue/object-curly-newline': ['error', {
  164. multiline: true,
  165. consistent: true
  166. }],
  167. 'vue/object-curly-spacing': ['error', 'always'],
  168. 'vue/object-property-newline': ['error', {
  169. allowMultiplePropertiesPerLine: true
  170. }],
  171. 'vue/object-shorthand': ['error', 'always', {
  172. ignoreConstructors: false,
  173. avoidQuotes: true,
  174. }],
  175. 'vue/operator-linebreak': ['error', 'before'],
  176. 'vue/prefer-template': 'error',
  177. 'vue/quote-props': ['error', 'consistent-as-needed'],
  178. 'vue/space-in-parens': ['error', 'never'],
  179. 'vue/space-infix-ops': 'error',
  180. 'vue/space-unary-ops': ['error', {
  181. words: true,
  182. nonwords: false
  183. }],
  184. 'vue/template-curly-spacing': 'error',
  185. },
  186. };