eslint.config.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import pluginVue from "eslint-plugin-vue"
  2. import vueTsEslintConfig from "@vue/eslint-config-typescript"
  3. import skipFormatting from "@vue/eslint-config-prettier/skip-formatting"
  4. export default [
  5. {
  6. name: "app/files-to-lint",
  7. files: ["**/*.{ts,mts,tsx,vue}"]
  8. },
  9. {
  10. name: "app/files-to-ignore",
  11. ignores: ["**/dist/**", "**/dist-ssr/**", "**/coverage/**"]
  12. },
  13. ...pluginVue.configs["flat/essential"],
  14. ...vueTsEslintConfig(),
  15. skipFormatting,
  16. {
  17. name: "app/custom-rules",
  18. rules: {
  19. "no-debugger": process.env.NODE_ENV == "production" ? 2 : 1,
  20. "no-unreachable": process.env.NODE_ENV == "production" ? 2 : 1, //return 警告不报错
  21. "no-undef": "off", // 没有声明的变量
  22. "vue/no-v-html": "off",
  23. "no-irregular-whitespace": "off",
  24. "vue/html-self-closing": [
  25. "error",
  26. {
  27. html: {
  28. void: "always",
  29. normal: "never",
  30. component: "always"
  31. },
  32. svg: "always",
  33. math: "always"
  34. }
  35. ],
  36. "vue/multi-word-component-names": "off", // 关闭驼峰命名
  37. "@typescript-eslint/no-unused-expressions": "off", // 关闭规则提示
  38. /* ts相关 */
  39. "@typescript-eslint/no-empty-function": "off", // 可以为空函数
  40. "@typescript-eslint/explicit-module-boundary-types": "off", //函数不需要返回类型也可以
  41. "@typescript-eslint/no-explicit-any": "off", //可以为any
  42. "@typescript-eslint/no-non-null-assertion": "off", //! 非空断言
  43. "@typescript-eslint/no-this-alias": "off" //忽略this关键字
  44. }
  45. }
  46. ]