mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-19 13:23:50 +03:00
Resolves all 28 react-hooks/* compiler violations (24 set-state-in-effect, 4 refs) across the 18 dashboard/providers files of batch 2 and removes their suppression entries — no eslint-disable, no new suppressions. Techniques per file: - Fetch-on-mount loaders (CustomModelsSection, ProviderCcAliasSection, ProviderInterceptionSection, ProviderParamFilterSection, page.tsx, useProviderConnections, useProviderSettings, CliproxyAccountHealthCard, DarioAccountPanel, NinerouterModelList): network/parse/error concerns extracted to module-level helpers returning error-as-value; the async glue is defined INSIDE each effect with every setState after the await. Loaders that handlers still need (refresh/retry buttons, exposed hook API) remain as callbacks; spinner flags moved into the button handlers. - Loading flags for provider-keyed sections derived from a loadedProviderId marker instead of synchronous setLoading(true) resets. - Modal init/reset effects (EditConnectionModal, EditCompatibleNodeModal, AddCompatibleProviderModal, VolcengineConnectModal state reset, useProviderUrlFilters hydration, page.tsx display-mode fallback, useProviderSettings per-provider flag reset): converted to render-phase adjustments guarded by the previously-seen prop/marker (react.dev "adjusting state when a prop changes"). - VolcengineConnectModal: phone prefill via localStorage lazy initializer; server-side session cancel + poll stop moved to the cleanup of an open-scoped effect reading a session ref mirror. - ModelCompatPopover refs: render-time ref mirrors removed — headerRowsRef is maintained by an applyHeaderRows writer used by all handlers, paramTargetRef is mirrored in an effect, and blockText/allowText mirrors were already kept in sync by their single writer (applyParamFields). - ModelCompatPopover state: header-row loading and value-visibility resets moved from [open, protocol] effects into the open/protocol/outside-click gesture handlers; the closed-popover rect reset was dropped (render is gated on open and the rect is recomputed pre-paint on reopen). - useRiskAcknowledged: localStorage mirrored via useSyncExternalStore with a module-level listener set notified by acknowledgeProviderRisk. - useProviderModels: loading for the empty-providerId case derived at the return site instead of a synchronous setLoading in the effect. Validation: scoped eslint with the suppressions file passes with 0 problems; check-dashboard-typecheck.mjs OK; node --test batch (14 files) and vitest batch (9 files, 47 tests) green. Refs #12146