.eslintrc.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. "@typescript-eslint/no-unused-vars": "off",
  40. // 一处使用hypen和一处不使用hypen,让字符搜索变得困难
  41. "vue/attribute-hyphenation": ["error", "never"],
  42. "vue/v-on-event-hyphenation": ["error", "never", { autofix: true }],
  43. "vue/no-v-html": "off",
  44. // TODO: https://github.com/vuejs/rfcs/discussions/369 defineProps deconstructure retain reactivity
  45. // eslint-disable-next-line vue/no-setup-props-destructure
  46. "vue/no-setup-props-destructure": "off",
  47. "@typescript-eslint/no-unsafe-argument": "off",
  48. },
  49. ignorePatterns: [
  50. // FIXME: ignore lang="tsx" don't know how to fix
  51. "RemainTime.vue",
  52. ".eslintrc.js",
  53. "vite.config.ts",
  54. "vitest.config.ts",
  55. "src/test",
  56. "test",
  57. "prebuild.mjs",
  58. ],
  59. overrides: [
  60. {
  61. files: ["src/**/**.vue"],
  62. parser: "vue-eslint-parser",
  63. parserOptions: {
  64. parser: {
  65. // Script parser for `<script>`
  66. js: "espree",
  67. // Script parser for `<script lang="ts">`
  68. ts: "@typescript-eslint/parser",
  69. // Script parser for vue directives (e.g. `v-if=` or `:attribute=`)
  70. // and vue interpolations (e.g. `{{variable}}`).
  71. // If not specified, the parser determined by `<script lang ="...">` is used.
  72. "<template>": "@typescript-eslint/parser",
  73. },
  74. project: ["tsconfig.json"],
  75. },
  76. globals: {
  77. $ref: true,
  78. $computed: true,
  79. $$: true,
  80. $message: true,
  81. $dialog: true,
  82. _hmt: true,
  83. },
  84. },
  85. ],
  86. };