eslint.config.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import reactHooks from "eslint-plugin-react-hooks";
  2. import tseslint from "typescript-eslint";
  3. /**
  4. * 分成管理 D-7:仅开启 rules-of-hooks 硬门禁(条件性 Hook ⇒ 硬加载白屏)。
  5. * 发布前跑 `npm run lint:hooks`。⛔ 夹带其它 lint 规则(会把存量文案/禁用注释打成失败)。
  6. */
  7. export default tseslint.config(
  8. {
  9. ignores: ["dist/**", "node_modules/**"],
  10. },
  11. {
  12. files: ["src/**/*.{js,jsx,ts,tsx}"],
  13. languageOptions: {
  14. parser: tseslint.parser,
  15. parserOptions: {
  16. ecmaFeatures: { jsx: true },
  17. },
  18. },
  19. linterOptions: {
  20. // 存量文件里有其它规则的 eslint-disable;本配置未启用那些规则 ⇒ 关掉「未使用指令」噪音。
  21. reportUnusedDisableDirectives: "off",
  22. },
  23. plugins: {
  24. "react-hooks": reactHooks,
  25. },
  26. rules: {
  27. "react-hooks/rules-of-hooks": "error",
  28. // exhaustive-deps 本轮不进硬门禁(存量注释多,单独治理)。
  29. "react-hooks/exhaustive-deps": "off",
  30. },
  31. },
  32. );