.eslintrc.cjs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. module.exports = {
  2. root: true,
  3. env: {
  4. browser: true,
  5. es2021: true,
  6. node: true,
  7. },
  8. parser: "vue-eslint-parser",
  9. extends: [
  10. // https://eslint.vuejs.org/user-guide/#usage
  11. "plugin:vue/vue3-recommended",
  12. "./.eslintrc-auto-import.json",
  13. "prettier",
  14. "plugin:@typescript-eslint/recommended",
  15. "plugin:prettier/recommended",
  16. ],
  17. parserOptions: {
  18. ecmaVersion: "latest",
  19. sourceType: "module",
  20. parser: "@typescript-eslint/parser",
  21. project: "./tsconfig.*?.json",
  22. createDefaultProgram: false,
  23. extraFileExtensions: [".vue"],
  24. },
  25. plugins: ["vue", "@typescript-eslint"],
  26. rules: {
  27. // https://eslint.vuejs.org/rules/#priority-a-essential-error-prevention
  28. "vue/multi-word-component-names": "off",
  29. "vue/no-v-model-argument": "off",
  30. "vue/script-setup-uses-vars": "error",
  31. "vue/no-reserved-component-names": "off",
  32. "vue/custom-event-name-casing": "off",
  33. "vue/attributes-order": "off",
  34. "vue/one-component-per-file": "off",
  35. "vue/html-closing-bracket-newline": "off",
  36. "vue/max-attributes-per-line": "off",
  37. "vue/multiline-html-element-content-newline": "off",
  38. "vue/singleline-html-element-content-newline": "off",
  39. "vue/attribute-hyphenation": "off",
  40. "vue/require-default-prop": "off",
  41. "vue/require-explicit-emits": "off",
  42. "vue/html-self-closing": [
  43. "error",
  44. {
  45. html: {
  46. void: "always",
  47. normal: "never",
  48. component: "always",
  49. },
  50. svg: "always",
  51. math: "always",
  52. },
  53. ],
  54. "@typescript-eslint/no-empty-function": "off", // 关闭空方法检查
  55. "@typescript-eslint/no-explicit-any": "off", // 关闭any类型的警告
  56. "@typescript-eslint/no-non-null-assertion": "off",
  57. "@typescript-eslint/ban-ts-ignore": "off",
  58. "@typescript-eslint/ban-ts-comment": "off",
  59. "@typescript-eslint/ban-types": "off",
  60. "@typescript-eslint/explicit-function-return-type": "off",
  61. "@typescript-eslint/no-explicit-any": "off",
  62. "@typescript-eslint/no-var-requires": "off",
  63. "@typescript-eslint/no-empty-function": "off",
  64. "@typescript-eslint/no-use-before-define": "off",
  65. "@typescript-eslint/no-non-null-assertion": "off",
  66. "@typescript-eslint/explicit-module-boundary-types": "off",
  67. "@typescript-eslint/no-unused-vars": "off",
  68. "prettier/prettier": [
  69. "error",
  70. {
  71. useTabs: false, // 不使用制表符
  72. },
  73. ],
  74. "vue/no-v-html": "off", // 关闭v-html检查
  75. },
  76. // eslint不能对html文件生效
  77. overrides: [
  78. {
  79. files: ["*.html"],
  80. processor: "vue/.vue",
  81. },
  82. ],
  83. // https://eslint.org/docs/latest/use/configure/language-options#specifying-globals
  84. globals: {
  85. OptionType: "readonly",
  86. },
  87. };