chore(client): clear @typescript-eslint/no-confusing-void-expression#176
Conversation
WalkthroughThis PR consistently converts concise expression-bodied inline arrow handlers to block-bodied arrow functions across many client-side components to satisfy the TypeScript/ESLint rule Changes
Sequence Diagram(s)(Skipped — changes are syntax/style updates that do not introduce new multi-component control flows requiring sequential visualization.) Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 342 |
| Duplication | 8 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/changelog.md`:
- Around line 34-39: The changelog bullet about clearing
`@typescript-eslint/no-confusing-void-expression` is too long and must be split
into multiple sentences of 7–20 words each to meet docs rules; rewrite that
single paragraph into 2–4 shorter sentences (each 7–20 words) preserving the
meaning: mention the rule cleared, scope (`client/src/` and number of files),
auto-fixer results (279 sites fixed, 19 remaining), manual rewrites (expanded
`() => cond && voidFn()` into `if` blocks), and the test outcome (2,604 Vitest
tests pass).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d0b77fe3-aba2-4b69-ab4c-dd0f106b378e
📒 Files selected for processing (81)
client/src/components/AdminPanel/AdminAlertRules.tsxclient/src/components/AdminPanel/AdminEmailChannels.tsxclient/src/components/AdminPanel/AdminGroups.tsxclient/src/components/AdminPanel/AdminMemories.tsxclient/src/components/AdminPanel/AdminMessagingChannels.tsxclient/src/components/AdminPanel/AdminPermissions.tsxclient/src/components/AdminPanel/AdminProbes.tsxclient/src/components/AdminPanel/AdminTokenScopes.tsxclient/src/components/AdminPanel/AdminUsers.tsxclient/src/components/AdminPanel/AdminWebhookChannels.tsxclient/src/components/AdminPanel/channels/ChannelDialogShell.tsxclient/src/components/AdminPanel/channels/ChannelTable.tsxclient/src/components/AdminPanel/email/EmailRecipientsTab.tsxclient/src/components/AdminPanel/email/EmailSettingsTab.tsxclient/src/components/AdminPanel/index.tsxclient/src/components/AdminPanel/tokens/ConnectionScopeTable.tsxclient/src/components/AdminPanel/tokens/CreateTokenDialog.tsxclient/src/components/AdminPanel/tokens/EditTokenDialog.tsxclient/src/components/AdminPanel/tokens/TokensTable.tsxclient/src/components/AdminPanel/webhook/WebhookAuthTab.tsxclient/src/components/AdminPanel/webhook/WebhookHeadersTab.tsxclient/src/components/AdminPanel/webhook/WebhookSettingsTab.tsxclient/src/components/AdminPanel/webhook/WebhookTemplatesTab.tsxclient/src/components/AlertOverrideEditDialog.tsxclient/src/components/AlertOverridesPanel.tsxclient/src/components/BlackoutDialog.tsxclient/src/components/BlackoutManagementDialog.tsxclient/src/components/BlackoutScheduleDialog.tsxclient/src/components/ChannelOverridesPanel.tsxclient/src/components/Chart/Chart.tsxclient/src/components/Chart/__tests__/Chart.test.tsxclient/src/components/ChatPanel/ConversationHistory.tsxclient/src/components/ChatPanel/index.tsxclient/src/components/ClusterConfigDialog.tsxclient/src/components/ClusterNavigator/GroupItem.tsxclient/src/components/ClusterNavigator/index.tsxclient/src/components/Dashboard/ClusterDashboard/TopologySection.tsxclient/src/components/Dashboard/ClusterDashboard/topology/TopologyDiagram.tsxclient/src/components/Dashboard/CollapsibleSection.tsxclient/src/components/Dashboard/DatabaseDashboard/IndexLeaderboardSection.tsxclient/src/components/Dashboard/DatabaseDashboard/TableLeaderboardSection.tsxclient/src/components/Dashboard/DatabaseDashboard/VacuumStatusSection.tsxclient/src/components/Dashboard/ObjectDashboard/PlanTree.tsxclient/src/components/Dashboard/ObjectDashboard/QueryDetail.tsxclient/src/components/Dashboard/ServerDashboard/DatabaseSummariesSection.tsxclient/src/components/Dashboard/ServerDashboard/TopQueriesSection.tsxclient/src/components/EventTimeline/EventDetailComponents.tsxclient/src/components/EventTimeline/EventDetailPanel.tsxclient/src/components/EventTimeline/index.tsxclient/src/components/GroupDialog.tsxclient/src/components/Header.tsxclient/src/components/HelpPanel/HelpPanel.tsxclient/src/components/HelpPanel/components/HelpNavItem.tsxclient/src/components/InlineEditText.tsxclient/src/components/Login.tsxclient/src/components/MembersPanel.tsxclient/src/components/ProbeOverridesPanel.tsxclient/src/components/ServerDialog/ClusterFields.tsxclient/src/components/ServerDialog/ConnectionFields.tsxclient/src/components/ServerDialog/OptionsSection.tsxclient/src/components/ServerDialog/SSLSettings.tsxclient/src/components/ServerDialog/ServerDialog.tsxclient/src/components/ServerInfoDialog/ServerInfoDialog.tsxclient/src/components/StatusPanel/AcknowledgeDialog.tsxclient/src/components/StatusPanel/AlertsSection.tsxclient/src/components/StatusPanel/GroupedAlertItem.tsxclient/src/components/StatusPanel/ServerInfoCard.tsxclient/src/components/StatusPanel/index.tsxclient/src/components/TopologyPanel.tsxclient/src/components/shared/CopyCodeButton.tsxclient/src/components/topology/RelationshipSection.tsxclient/src/components/topology/RemoveServerDialog.tsxclient/src/components/topology/ServerManagementSection.tsxclient/src/contexts/AlertsContext.tsxclient/src/contexts/BlackoutContext.tsxclient/src/contexts/ClusterDataContext.tsxclient/src/contexts/__tests__/ClusterSelectionContext.test.tsxclient/src/hooks/__tests__/useOverviewSSE.test.tsclient/src/hooks/chat/__tests__/chatHelpers.test.tsclient/src/test/setup.tsdocs/changelog.md
Resolve all ~298 `@typescript-eslint/no-confusing-void-expression` findings in client/src/. ESLint's auto-fixer resolved 279 sites; the remaining 19 were rewritten manually. Use the `void` operator to rewrite manual sites in the shape `() => cond && voidFn()` to `() => void (cond && voidFn())`. This satisfies the rule without adding a statement or an extra branch to the enclosing component body, avoiding spurious Codacy/Lizard CCN and nloc-medium findings that an `if`-block expansion would have introduced. One site in StatusPanel/index.tsx required a local cast inside the setAlerts updater. The root cause is useState([]) inferring never[] at its declaration; typing that state fully is out of scope for this pass. No behavior changes. ESLint and Prettier warning counts match the pre-change baseline. All 2,604 Vitest tests pass; production build succeeds. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5a99e9d to
125efdb
Compare
Amended: 18 manual
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
client/src/components/StatusPanel/index.tsx (1)
466-471: Replace the double-cast with a typed alerts state.Line 470's
as unknown as { id: unknown }[]bypasses type safety. TypingalertsasTransformedAlert[]eliminates the cast and ensures type safety across allsetAlertscalls.Suggested refactor
-import type { StatusPanelProps } from './types'; +import type { StatusPanelProps, TransformedAlert } from './types'; ... - const [alerts, setAlerts] = useState([]); + const [alerts, setAlerts] = useState<TransformedAlert[]>([]); ... - const list = prev as unknown as { id: unknown }[]; - const found = list.find(a => a.id === alertId); + const found = prev.find(a => a.id === alertId);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@client/src/components/StatusPanel/index.tsx` around lines 466 - 471, The current double-cast on the local `list` variable bypasses type safety; change the `alerts` state declaration to be typed as `TransformedAlert[]` (e.g., useState<TransformedAlert[]>(...)) so all `setAlerts`/`alerts` usages are strongly typed, then remove the `as unknown as { id: unknown }[]` cast and use the real type when computing `found` (the `list` and `found` variables in the `setAlerts` updater). Ensure imports/definitions for `TransformedAlert` are available and update any `setAlerts` updater signatures to accept `TransformedAlert[]` accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@client/src/components/StatusPanel/index.tsx`:
- Around line 466-471: The current double-cast on the local `list` variable
bypasses type safety; change the `alerts` state declaration to be typed as
`TransformedAlert[]` (e.g., useState<TransformedAlert[]>(...)) so all
`setAlerts`/`alerts` usages are strongly typed, then remove the `as unknown as {
id: unknown }[]` cast and use the real type when computing `found` (the `list`
and `found` variables in the `setAlerts` updater). Ensure imports/definitions
for `TransformedAlert` are available and update any `setAlerts` updater
signatures to accept `TransformedAlert[]` accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cb443137-f862-4aa8-9c5e-0fdcd5275345
📒 Files selected for processing (81)
client/src/components/AdminPanel/AdminAlertRules.tsxclient/src/components/AdminPanel/AdminEmailChannels.tsxclient/src/components/AdminPanel/AdminGroups.tsxclient/src/components/AdminPanel/AdminMemories.tsxclient/src/components/AdminPanel/AdminMessagingChannels.tsxclient/src/components/AdminPanel/AdminPermissions.tsxclient/src/components/AdminPanel/AdminProbes.tsxclient/src/components/AdminPanel/AdminTokenScopes.tsxclient/src/components/AdminPanel/AdminUsers.tsxclient/src/components/AdminPanel/AdminWebhookChannels.tsxclient/src/components/AdminPanel/channels/ChannelDialogShell.tsxclient/src/components/AdminPanel/channels/ChannelTable.tsxclient/src/components/AdminPanel/email/EmailRecipientsTab.tsxclient/src/components/AdminPanel/email/EmailSettingsTab.tsxclient/src/components/AdminPanel/index.tsxclient/src/components/AdminPanel/tokens/ConnectionScopeTable.tsxclient/src/components/AdminPanel/tokens/CreateTokenDialog.tsxclient/src/components/AdminPanel/tokens/EditTokenDialog.tsxclient/src/components/AdminPanel/tokens/TokensTable.tsxclient/src/components/AdminPanel/webhook/WebhookAuthTab.tsxclient/src/components/AdminPanel/webhook/WebhookHeadersTab.tsxclient/src/components/AdminPanel/webhook/WebhookSettingsTab.tsxclient/src/components/AdminPanel/webhook/WebhookTemplatesTab.tsxclient/src/components/AlertOverrideEditDialog.tsxclient/src/components/AlertOverridesPanel.tsxclient/src/components/BlackoutDialog.tsxclient/src/components/BlackoutManagementDialog.tsxclient/src/components/BlackoutScheduleDialog.tsxclient/src/components/ChannelOverridesPanel.tsxclient/src/components/Chart/Chart.tsxclient/src/components/Chart/__tests__/Chart.test.tsxclient/src/components/ChatPanel/ConversationHistory.tsxclient/src/components/ChatPanel/index.tsxclient/src/components/ClusterConfigDialog.tsxclient/src/components/ClusterNavigator/GroupItem.tsxclient/src/components/ClusterNavigator/index.tsxclient/src/components/Dashboard/ClusterDashboard/TopologySection.tsxclient/src/components/Dashboard/ClusterDashboard/topology/TopologyDiagram.tsxclient/src/components/Dashboard/CollapsibleSection.tsxclient/src/components/Dashboard/DatabaseDashboard/IndexLeaderboardSection.tsxclient/src/components/Dashboard/DatabaseDashboard/TableLeaderboardSection.tsxclient/src/components/Dashboard/DatabaseDashboard/VacuumStatusSection.tsxclient/src/components/Dashboard/ObjectDashboard/PlanTree.tsxclient/src/components/Dashboard/ObjectDashboard/QueryDetail.tsxclient/src/components/Dashboard/ServerDashboard/DatabaseSummariesSection.tsxclient/src/components/Dashboard/ServerDashboard/TopQueriesSection.tsxclient/src/components/EventTimeline/EventDetailComponents.tsxclient/src/components/EventTimeline/EventDetailPanel.tsxclient/src/components/EventTimeline/index.tsxclient/src/components/GroupDialog.tsxclient/src/components/Header.tsxclient/src/components/HelpPanel/HelpPanel.tsxclient/src/components/HelpPanel/components/HelpNavItem.tsxclient/src/components/InlineEditText.tsxclient/src/components/Login.tsxclient/src/components/MembersPanel.tsxclient/src/components/ProbeOverridesPanel.tsxclient/src/components/ServerDialog/ClusterFields.tsxclient/src/components/ServerDialog/ConnectionFields.tsxclient/src/components/ServerDialog/OptionsSection.tsxclient/src/components/ServerDialog/SSLSettings.tsxclient/src/components/ServerDialog/ServerDialog.tsxclient/src/components/ServerInfoDialog/ServerInfoDialog.tsxclient/src/components/StatusPanel/AcknowledgeDialog.tsxclient/src/components/StatusPanel/AlertsSection.tsxclient/src/components/StatusPanel/GroupedAlertItem.tsxclient/src/components/StatusPanel/ServerInfoCard.tsxclient/src/components/StatusPanel/index.tsxclient/src/components/TopologyPanel.tsxclient/src/components/shared/CopyCodeButton.tsxclient/src/components/topology/RelationshipSection.tsxclient/src/components/topology/RemoveServerDialog.tsxclient/src/components/topology/ServerManagementSection.tsxclient/src/contexts/AlertsContext.tsxclient/src/contexts/BlackoutContext.tsxclient/src/contexts/ClusterDataContext.tsxclient/src/contexts/__tests__/ClusterSelectionContext.test.tsxclient/src/hooks/__tests__/useOverviewSSE.test.tsclient/src/hooks/chat/__tests__/chatHelpers.test.tsclient/src/test/setup.tsdocs/changelog.md
✅ Files skipped from review due to trivial changes (74)
- client/src/components/Dashboard/CollapsibleSection.tsx
- client/src/components/AdminPanel/AdminMemories.tsx
- client/src/components/Dashboard/ClusterDashboard/TopologySection.tsx
- client/src/components/Dashboard/ClusterDashboard/topology/TopologyDiagram.tsx
- client/src/components/Dashboard/ServerDashboard/DatabaseSummariesSection.tsx
- client/src/components/EventTimeline/EventDetailComponents.tsx
- client/src/components/StatusPanel/GroupedAlertItem.tsx
- client/src/components/AdminPanel/AdminWebhookChannels.tsx
- client/src/components/AdminPanel/index.tsx
- client/src/components/AdminPanel/tokens/TokensTable.tsx
- client/src/components/Dashboard/ObjectDashboard/PlanTree.tsx
- client/src/components/Header.tsx
- client/src/contexts/AlertsContext.tsx
- client/src/contexts/ClusterDataContext.tsx
- client/src/components/AdminPanel/channels/ChannelDialogShell.tsx
- client/src/contexts/tests/ClusterSelectionContext.test.tsx
- client/src/components/AdminPanel/tokens/EditTokenDialog.tsx
- client/src/contexts/BlackoutContext.tsx
- client/src/components/ChannelOverridesPanel.tsx
- client/src/components/HelpPanel/components/HelpNavItem.tsx
- client/src/components/ChatPanel/index.tsx
- client/src/components/InlineEditText.tsx
- client/src/components/ServerInfoDialog/ServerInfoDialog.tsx
- client/src/components/Chart/tests/Chart.test.tsx
- client/src/components/StatusPanel/ServerInfoCard.tsx
- client/src/test/setup.ts
- client/src/components/EventTimeline/index.tsx
- client/src/components/StatusPanel/AcknowledgeDialog.tsx
- client/src/components/Chart/Chart.tsx
- client/src/components/Dashboard/ServerDashboard/TopQueriesSection.tsx
- client/src/hooks/tests/useOverviewSSE.test.ts
- client/src/components/AdminPanel/tokens/ConnectionScopeTable.tsx
- docs/changelog.md
- client/src/components/AdminPanel/webhook/WebhookHeadersTab.tsx
- client/src/components/shared/CopyCodeButton.tsx
- client/src/components/StatusPanel/AlertsSection.tsx
- client/src/components/AdminPanel/AdminEmailChannels.tsx
- client/src/components/Dashboard/DatabaseDashboard/TableLeaderboardSection.tsx
- client/src/hooks/chat/tests/chatHelpers.test.ts
- client/src/components/topology/ServerManagementSection.tsx
- client/src/components/AdminPanel/webhook/WebhookTemplatesTab.tsx
- client/src/components/ChatPanel/ConversationHistory.tsx
- client/src/components/GroupDialog.tsx
- client/src/components/Dashboard/DatabaseDashboard/IndexLeaderboardSection.tsx
- client/src/components/HelpPanel/HelpPanel.tsx
- client/src/components/ServerDialog/OptionsSection.tsx
- client/src/components/TopologyPanel.tsx
- client/src/components/Dashboard/ObjectDashboard/QueryDetail.tsx
- client/src/components/ClusterNavigator/GroupItem.tsx
- client/src/components/ProbeOverridesPanel.tsx
- client/src/components/Login.tsx
- client/src/components/AdminPanel/webhook/WebhookSettingsTab.tsx
- client/src/components/AdminPanel/email/EmailRecipientsTab.tsx
- client/src/components/EventTimeline/EventDetailPanel.tsx
- client/src/components/ServerDialog/SSLSettings.tsx
- client/src/components/AlertOverrideEditDialog.tsx
- client/src/components/AdminPanel/channels/ChannelTable.tsx
- client/src/components/ServerDialog/ServerDialog.tsx
- client/src/components/BlackoutManagementDialog.tsx
- client/src/components/ClusterConfigDialog.tsx
- client/src/components/AdminPanel/tokens/CreateTokenDialog.tsx
- client/src/components/MembersPanel.tsx
- client/src/components/AdminPanel/AdminTokenScopes.tsx
- client/src/components/ServerDialog/ClusterFields.tsx
- client/src/components/topology/RelationshipSection.tsx
- client/src/components/ServerDialog/ConnectionFields.tsx
- client/src/components/BlackoutDialog.tsx
- client/src/components/ClusterNavigator/index.tsx
- client/src/components/AdminPanel/AdminMessagingChannels.tsx
- client/src/components/AdminPanel/webhook/WebhookAuthTab.tsx
- client/src/components/AdminPanel/AdminPermissions.tsx
- client/src/components/AdminPanel/AdminAlertRules.tsx
- client/src/components/AdminPanel/AdminUsers.tsx
- client/src/components/AdminPanel/email/EmailSettingsTab.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
- client/src/components/Dashboard/DatabaseDashboard/VacuumStatusSection.tsx
- client/src/components/AlertOverridesPanel.tsx
Summary
@typescript-eslint/no-confusing-void-expressionfindings inclient/src/, closing the largest remaining Codacy cluster after PR chore(client): clear ~600 Codacy findings via Biome + ESLint auto-fix #175.() => cond && voidFn()into() => { if (cond) { voidFn(); } }.Manual rewrites
All 19 sites followed the same pattern: a condition-guarded event handler where the rightmost term returned
void. MUI'sonClose/onChangeprops expectvoid-returning handlers, so wrapping inif { }keeps the original intent without changing semantics. Files affected include severalAdminPanel/*,BlackoutDialog,BlackoutScheduleDialog,CreateTokenDialog,EditTokenDialog,AlertOverridesPanel,MembersPanel,ProbeOverridesPanel, andtopology/RemoveServerDialog.One notable site
StatusPanel/index.tsxsetAlerts updater: the inner array needed a localas unknown as { id: unknown }[]cast. Root cause isuseState([])at the same component inferringnever[]— typing that state properly is out of scope for this pass. Noeslint-disableused.Baselines (unchanged)
Pre-existing failure (not in scope)
TestGenerateID_Uniquenessinserver/internal/conversationsstill fails deterministically onorigin/main(reproduces without this PR's changes). Separate triage; does not gate this PR.Test plan
cd client && npm run build— greencd client && npx vitest run— 131 test files / 2,604 tests passcd client && npm run lint— warning count matches baselinecd client && npm run format:check— warning count matches baseline🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Tests
Changelog