.eslintrc.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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"],
  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. ],
  30. rules: {
  31. // 和 $ref let 冲突, fixed vue@3.2.26
  32. // "prefer-const": "off",
  33. "@typescript-eslint/no-explicit-any": "off",
  34. "@typescript-eslint/ban-ts-comment": "off",
  35. "@typescript-eslint/no-unsafe-assignment": "off",
  36. "@typescript-eslint/no-unsafe-member-access": "off",
  37. "@typescript-eslint/restrict-plus-operands": "off",
  38. "@typescript-eslint/restrict-template-expressions": "off",
  39. "@typescript-eslint/no-non-null-assertion": "off",
  40. "@typescript-eslint/no-unsafe-call": "off",
  41. "@typescript-eslint/no-unsafe-return": "off",
  42. "@typescript-eslint/no-unsafe-argument": "off",
  43. // 一处使用hypen和一处不使用hypen,让字符搜索变得困难
  44. "vue/attribute-hyphenation": ["error", "never"],
  45. "vue/v-on-event-hyphenation": ["error", "never", { autofix: true }],
  46. "vue/no-v-html": "off",
  47. // TODO: https://github.com/vuejs/rfcs/discussions/369 defineProps deconstructure retain reactivity
  48. // eslint-disable-next-line vue/no-setup-props-destructure
  49. "vue/no-setup-props-destructure": "off",
  50. "vue/multi-word-component-names": "off",
  51. "vue/no-unsafe-call": "off",
  52. "vue/no-unsafe-return": "off",
  53. "vue/no-unsafe-argument": "off",
  54. },
  55. ignorePatterns: [
  56. ".eslintrc.js",
  57. "vite.config.ts",
  58. "src/test",
  59. "prebuild.mjs",
  60. ],
  61. overrides: [
  62. {
  63. files: ["src/**/**.vue"],
  64. parser: "vue-eslint-parser",
  65. parserOptions: {
  66. parser: {
  67. // Script parser for `<script>`
  68. js: "espree",
  69. // Script parser for `<script lang="ts">`
  70. ts: "@typescript-eslint/parser",
  71. // Script parser for vue directives (e.g. `v-if=` or `:attribute=`)
  72. // and vue interpolations (e.g. `{{variable}}`).
  73. // If not specified, the parser determined by `<script lang ="...">` is used.
  74. "<template>": "@typescript-eslint/parser",
  75. },
  76. project: ["tsconfig.json"],
  77. },
  78. globals: {
  79. $ref: true,
  80. $computed: true,
  81. $$: true,
  82. },
  83. },
  84. ],
  85. };