.eslintrc.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. },
  44. ignorePatterns: [
  45. ".eslintrc.js",
  46. "vite.config.ts",
  47. "vitest.config.ts",
  48. "src/test",
  49. "test",
  50. "prebuild.mjs",
  51. ],
  52. overrides: [
  53. {
  54. files: ["src/**/**.vue"],
  55. parser: "vue-eslint-parser",
  56. parserOptions: {
  57. parser: {
  58. // Script parser for `<script>`
  59. js: "espree",
  60. // Script parser for `<script lang="ts">`
  61. ts: "@typescript-eslint/parser",
  62. // Script parser for vue directives (e.g. `v-if=` or `:attribute=`)
  63. // and vue interpolations (e.g. `{{variable}}`).
  64. // If not specified, the parser determined by `<script lang ="...">` is used.
  65. "<template>": "espree",
  66. },
  67. project: ["tsconfig.json"],
  68. },
  69. globals: {
  70. $ref: true,
  71. $computed: true,
  72. $$: true,
  73. $message: true,
  74. $dialog: true,
  75. _hmt: true,
  76. },
  77. },
  78. ],
  79. };