.eslintrc.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @type {import("eslint").Linter.Config}
  3. */
  4. module.exports = {
  5. root: true,
  6. env: {
  7. node: true,
  8. browser: true,
  9. "vue/setup-compiler-macros": true,
  10. },
  11. parser: "@typescript-eslint/parser",
  12. parserOptions: {
  13. ecmaVersion: "2021",
  14. sourceType: "module",
  15. ecmaFeatures: {
  16. jsx: true,
  17. },
  18. tsconfigRootDir: "./",
  19. project: ["tsconfig.json"],
  20. extraFileExtensions: [".vue", ".config.js"],
  21. },
  22. plugins: ["@typescript-eslint"],
  23. extends: [
  24. "eslint:recommended",
  25. "plugin:@typescript-eslint/recommended",
  26. "plugin:@typescript-eslint/recommended-requiring-type-checking",
  27. "plugin:vue/vue3-recommended",
  28. "prettier",
  29. "./.eslintrc-auto-import.json",
  30. ],
  31. rules: {
  32. "@typescript-eslint/no-explicit-any": "off",
  33. "@typescript-eslint/ban-ts-comment": "off",
  34. "@typescript-eslint/no-unsafe-assignment": "off",
  35. "@typescript-eslint/no-unsafe-member-access": "off",
  36. "@typescript-eslint/restrict-plus-operands": "off",
  37. "@typescript-eslint/restrict-template-expressions": "off",
  38. "@typescript-eslint/no-non-null-assertion": "off",
  39. // 一处使用hypen和一处不使用hypen,让字符搜索变得困难
  40. "vue/attribute-hyphenation": ["error", "never"],
  41. "vue/v-on-event-hyphenation": ["error", "never", { autofix: true }],
  42. "vue/no-v-html": "off",
  43. // TODO: https://github.com/vuejs/rfcs/discussions/369 defineProps deconstructure retain reactivity
  44. // eslint-disable-next-line vue/no-setup-props-destructure
  45. "vue/no-setup-props-destructure": "off",
  46. },
  47. ignorePatterns: [
  48. // FIXME: ignore lang="tsx" don't know how to fix
  49. "RemainTime.vue",
  50. ".eslintrc.js",
  51. "vite.config.ts",
  52. "vitest.config.ts",
  53. "src/test",
  54. "test",
  55. "prebuild.mjs",
  56. ],
  57. overrides: [
  58. {
  59. files: ["src/**/**.vue"],
  60. parser: "vue-eslint-parser",
  61. parserOptions: {
  62. parser: {
  63. // Script parser for `<script>`
  64. js: "espree",
  65. // Script parser for `<script lang="ts">`
  66. ts: "@typescript-eslint/parser",
  67. // Script parser for vue directives (e.g. `v-if=` or `:attribute=`)
  68. // and vue interpolations (e.g. `{{variable}}`).
  69. // If not specified, the parser determined by `<script lang ="...">` is used.
  70. "<template>": "espree",
  71. },
  72. project: ["tsconfig.json"],
  73. },
  74. globals: {
  75. $ref: true,
  76. $computed: true,
  77. $$: true,
  78. $message: true,
  79. $dialog: true,
  80. _hmt: true,
  81. },
  82. },
  83. ],
  84. };