fix(lint): remove redundant default case from exhaustive override-field switch#7451
Conversation
…ld switch pnpm lint fails on main since stablyai#7386: the override-field switch in SourceControlActionRepoOverrideNote covers every union variant, and the switch-exhaustiveness config sets allowDefaultCaseForExhaustiveSwitch: false, so the hand-rolled never-guard default is rejected. The lint rule itself already fails the build if the union grows a new variant, so the guard is redundant — remove it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughA default branch was removed from the switch statement in the getRecipeOverrideFieldLabel function within SourceControlActionRepoOverrideNote.tsx. This branch previously performed a compile-time exhaustiveness check by assigning the field value to a never-typed variable and returning it. The switch statement now ends after the commandTemplate case without this fallback handling. Changes
Related Issues: None specified. Related PRs: None specified. Suggested labels: None Suggested reviewers: None 🐰 A switch once guarded, exhaustive and tight, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
pnpm lintcurrently fails onmain:Introduced by #7386. The switch in
getRecipeOverrideFieldLabelcovers every variant ofSourceControlActionRecipeOverrideField, andconfig/oxlint-switch-exhaustiveness.jsonsetsallowDefaultCaseForExhaustiveSwitch: false, so the hand-rollednever-guard default case is rejected.This PR removes the default case. The dedicated
lint:switch-exhaustivenessrule already fails the build if the union grows a new variant, so the compile-time guard it replaced is redundant — this matches the convention everywhere else in the renderer (no other component uses the_exhaustivepattern). No user-visible change.Screenshots
No visual change.
Testing
pnpm lint(fails onmain, passes on this branch)pnpm typecheckpnpm test(24,518 passed / 32 skipped)pnpm buildSourceControlActionRepoOverrideNote.test.tsx(5/5 passing) exercises all three override-field labels; theswitch-exhaustiveness-checklint rule itself is the regression guard if the union grows a new variant, so no new tests were needed for a dead-code removal.AI Review Report
Reviewed with Claude Code. Main risks checked: (1) whether removing the default case could introduce an implicit-
undefinedreturn path — it cannot, TypeScript proves the switch exhaustive over the union andtsgo --noEmitpasses on all three tsconfigs; (2) whether the exhaustiveness safety net is weakened — it is not,typescript/switch-exhaustiveness-check(type-aware,allowDefaultCaseForExhaustiveSwitch: false) errors at lint time ifSourceControlActionRecipeOverrideFieldgains a variant this switch does not handle; (3) convention alignment — no other renderer component uses the_exhaustivenever-guard pattern. Cross-platform compatibility (macOS, Linux, Windows) was explicitly considered: the change is pure TypeScript control flow with no shortcuts, labels, paths, shell behavior, or Electron platform differences involved.Security Audit
No security surface touched: the change removes an unreachable dead-code branch from a pure label-mapping function in the renderer. No input handling, command execution, path handling, auth, secrets, dependency, or IPC changes. No follow-up needed.
Notes
No platform-specific behavior. Zero runtime behavior change — the removed branch was unreachable for every value of the union type.