You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
4.8 KiB

  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. export default defineFlatConfig([
  10. {
  11. ...js.configs.recommended,
  12. ignores: [
  13. "**/.*",
  14. "dist/*",
  15. "*.d.ts",
  16. "public/*",
  17. "src/assets/**",
  18. "src/**/iconfont/**"
  19. ],
  20. languageOptions: {
  21. globals: {
  22. // index.d.ts
  23. RefType: "readonly",
  24. EmitType: "readonly",
  25. TargetContext: "readonly",
  26. ComponentRef: "readonly",
  27. ElRef: "readonly",
  28. ForDataType: "readonly",
  29. AnyFunction: "readonly",
  30. PropType: "readonly",
  31. Writable: "readonly",
  32. Nullable: "readonly",
  33. NonNullable: "readonly",
  34. Recordable: "readonly",
  35. ReadonlyRecordable: "readonly",
  36. Indexable: "readonly",
  37. DeepPartial: "readonly",
  38. Without: "readonly",
  39. Exclusive: "readonly",
  40. TimeoutHandle: "readonly",
  41. IntervalHandle: "readonly",
  42. Effect: "readonly",
  43. ChangeEvent: "readonly",
  44. WheelEvent: "readonly",
  45. ImportMetaEnv: "readonly",
  46. Fn: "readonly",
  47. PromiseFn: "readonly",
  48. ComponentElRef: "readonly",
  49. parseInt: "readonly",
  50. parseFloat: "readonly"
  51. }
  52. },
  53. plugins: {
  54. prettier: pluginPrettier
  55. },
  56. rules: {
  57. ...configPrettier.rules,
  58. ...pluginPrettier.configs.recommended.rules,
  59. "no-debugger": "off",
  60. "no-unused-vars": [
  61. "error",
  62. {
  63. argsIgnorePattern: "^_",
  64. varsIgnorePattern: "^_"
  65. }
  66. ],
  67. "prettier/prettier": [
  68. "error",
  69. {
  70. endOfLine: "auto"
  71. }
  72. ]
  73. }
  74. },
  75. {
  76. files: ["**/*.?([cm])ts", "**/*.?([cm])tsx"],
  77. languageOptions: {
  78. parser: parserTypeScript,
  79. parserOptions: {
  80. sourceType: "module"
  81. }
  82. },
  83. plugins: {
  84. "@typescript-eslint": pluginTypeScript
  85. },
  86. rules: {
  87. ...pluginTypeScript.configs.strict.rules,
  88. "@typescript-eslint/ban-types": "off",
  89. "@typescript-eslint/no-redeclare": "error",
  90. "@typescript-eslint/ban-ts-comment": "off",
  91. "@typescript-eslint/no-explicit-any": "off",
  92. "@typescript-eslint/prefer-as-const": "warn",
  93. "@typescript-eslint/no-empty-function": "off",
  94. "@typescript-eslint/no-non-null-assertion": "off",
  95. "@typescript-eslint/no-import-type-side-effects": "error",
  96. "@typescript-eslint/explicit-module-boundary-types": "off",
  97. "@typescript-eslint/consistent-type-imports": [
  98. "error",
  99. { disallowTypeAnnotations: false, fixStyle: "inline-type-imports" }
  100. ],
  101. "@typescript-eslint/prefer-literal-enum-member": [
  102. "error",
  103. { allowBitwiseExpressions: true }
  104. ],
  105. "@typescript-eslint/no-unused-vars": [
  106. "error",
  107. {
  108. argsIgnorePattern: "^_",
  109. varsIgnorePattern: "^_"
  110. }
  111. ]
  112. }
  113. },
  114. {
  115. files: ["**/*.d.ts"],
  116. rules: {
  117. "eslint-comments/no-unlimited-disable": "off",
  118. "import/no-duplicates": "off",
  119. "unused-imports/no-unused-vars": "off"
  120. }
  121. },
  122. {
  123. files: ["**/*.?([cm])js"],
  124. rules: {
  125. "@typescript-eslint/no-require-imports": "off",
  126. "@typescript-eslint/no-var-requires": "off"
  127. }
  128. },
  129. {
  130. files: ["**/*.vue"],
  131. languageOptions: {
  132. globals: {
  133. $: "readonly",
  134. $$: "readonly",
  135. $computed: "readonly",
  136. $customRef: "readonly",
  137. $ref: "readonly",
  138. $shallowRef: "readonly",
  139. $toRef: "readonly"
  140. },
  141. parser: parserVue,
  142. parserOptions: {
  143. ecmaFeatures: {
  144. jsx: true
  145. },
  146. extraFileExtensions: [".vue"],
  147. parser: "@typescript-eslint/parser",
  148. sourceType: "module"
  149. }
  150. },
  151. plugins: {
  152. vue: pluginVue
  153. },
  154. processor: pluginVue.processors[".vue"],
  155. rules: {
  156. ...pluginVue.configs.base.rules,
  157. ...pluginVue.configs["vue3-essential"].rules,
  158. ...pluginVue.configs["vue3-recommended"].rules,
  159. "no-undef": "off",
  160. "no-unused-vars": "off",
  161. "vue/no-v-html": "off",
  162. "vue/require-default-prop": "off",
  163. "vue/require-explicit-emits": "off",
  164. "vue/multi-word-component-names": "off",
  165. "vue/no-setup-props-reactivity-loss": "off",
  166. "vue/html-self-closing": [
  167. "error",
  168. {
  169. html: {
  170. void: "always",
  171. normal: "always",
  172. component: "always"
  173. },
  174. svg: "always",
  175. math: "always"
  176. }
  177. ]
  178. }
  179. }
  180. ]);