.eslintrc.cjs 6.2 KB

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