eslint.config.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import js from "@eslint/js";
  2. import pluginVue from "eslint-plugin-vue";
  3. import * as parserVue from "vue-eslint-parser";
  4. import configPrettier from "eslint-config-prettier";
  5. import pluginPrettier from "eslint-plugin-prettier";
  6. import { defineFlatConfig } from "eslint-define-config";
  7. import * as parserTypeScript from "@typescript-eslint/parser";
  8. import pluginTypeScript from "@typescript-eslint/eslint-plugin";
  9. import globals from "globals";
  10. export default defineFlatConfig([
  11. {
  12. ...js.configs.recommended,
  13. ignores: ["**/.*", "dist/**/*", "*.d.ts", "public/*", "src/assets/**"],
  14. languageOptions: {
  15. globals: globals.browser
  16. },
  17. plugins: {
  18. prettier: pluginPrettier
  19. },
  20. rules: {
  21. ...configPrettier.rules,
  22. ...pluginPrettier.configs.recommended.rules,
  23. "no-debugger": "off",
  24. "no-unused-vars": [
  25. "error",
  26. {
  27. argsIgnorePattern: "^_",
  28. varsIgnorePattern: "^_"
  29. }
  30. ],
  31. "prettier/prettier": [
  32. "error",
  33. {
  34. endOfLine: "auto"
  35. }
  36. ]
  37. }
  38. },
  39. {
  40. files: ["**/*.?([cm])ts", "**/*.?([cm])tsx"],
  41. languageOptions: {
  42. parser: parserTypeScript,
  43. parserOptions: {
  44. sourceType: "module"
  45. }
  46. },
  47. plugins: {
  48. "@typescript-eslint": pluginTypeScript
  49. },
  50. rules: {
  51. ...pluginTypeScript.configs.strict.rules,
  52. "@typescript-eslint/ban-types": "off",
  53. "@typescript-eslint/no-redeclare": "error",
  54. "@typescript-eslint/ban-ts-comment": "off",
  55. "@typescript-eslint/no-explicit-any": "off",
  56. "@typescript-eslint/prefer-as-const": "warn",
  57. "@typescript-eslint/no-empty-function": "off",
  58. "@typescript-eslint/no-non-null-assertion": "off",
  59. "@typescript-eslint/no-import-type-side-effects": "error",
  60. "@typescript-eslint/explicit-module-boundary-types": "off",
  61. "@typescript-eslint/consistent-type-imports": [
  62. "error",
  63. {
  64. disallowTypeAnnotations: false,
  65. fixStyle: "inline-type-imports"
  66. }
  67. ],
  68. "@typescript-eslint/prefer-literal-enum-member": [
  69. "error",
  70. {
  71. allowBitwiseExpressions: true
  72. }
  73. ],
  74. "@typescript-eslint/no-unused-vars": [
  75. "error",
  76. {
  77. argsIgnorePattern: "^_",
  78. varsIgnorePattern: "^_"
  79. }
  80. ]
  81. }
  82. },
  83. {
  84. files: ["**/*.d.ts"],
  85. rules: {
  86. "eslint-comments/no-unlimited-disable": "off",
  87. "import/no-duplicates": "off",
  88. "unused-imports/no-unused-vars": "off"
  89. }
  90. },
  91. {
  92. files: ["**/*.?([cm])js"],
  93. rules: {
  94. "@typescript-eslint/no-require-imports": "off",
  95. "@typescript-eslint/no-var-requires": "off"
  96. }
  97. },
  98. {
  99. files: ["**/*.vue"],
  100. languageOptions: {
  101. globals: {
  102. $: "readonly",
  103. $$: "readonly",
  104. $computed: "readonly",
  105. $customRef: "readonly",
  106. $ref: "readonly",
  107. $shallowRef: "readonly",
  108. $toRef: "readonly"
  109. },
  110. parser: parserVue,
  111. parserOptions: {
  112. ecmaFeatures: {
  113. jsx: true
  114. },
  115. extraFileExtensions: [".vue"],
  116. parser: "@typescript-eslint/parser",
  117. sourceType: "module"
  118. }
  119. },
  120. plugins: {
  121. vue: pluginVue
  122. },
  123. processor: pluginVue.processors[".vue"],
  124. rules: {
  125. ...pluginVue.configs.base.rules,
  126. ...pluginVue.configs["vue3-essential"].rules,
  127. ...pluginVue.configs["vue3-recommended"].rules,
  128. "no-undef": "off",
  129. "no-unused-vars": "off",
  130. "vue/no-v-html": "off",
  131. "vue/require-default-prop": "off",
  132. "vue/require-explicit-emits": "off",
  133. "vue/multi-word-component-names": "off",
  134. "vue/no-setup-props-reactivity-loss": "off",
  135. "vue/html-self-closing": [
  136. "error",
  137. {
  138. html: {
  139. void: "always",
  140. normal: "always",
  141. component: "always"
  142. },
  143. svg: "always",
  144. math: "always"
  145. }
  146. ]
  147. }
  148. }
  149. ]);