Skip to content

Remove flag and experiment scaffolding, dead comment utilities and barrel-only exports - #1169

Merged
yattias merged 2 commits into
mainfrom
cleanup/4-flags-and-barrels
Oct 11, 2026
Merged

yattias merged 2 commits into
mainfrom
cleanup/4-flags-and-barrels

Conversation

@yattias

@yattias yattias commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Fourth chunk of the dead-code removal plan (docs/dead-code-report.md, kept local), following #1166.

What goes

  • Feature-flag scaffolding. utils/featureFlags.ts had one flag, hard-coded to true, a localStorage reader nobody called, a console helper installed on window, and DEBUG branches that were always off. The two isFeatureEnabled(...) checks in NoteEditorLayout were always true and are inlined. Only isProduction() had readers (the two legacy banners), so that is all that remains, without the debug branches.
  • Homepage experiment helper. utils/experiment.ts was reachable only through an unused import in contexts/UserContext.tsx.
  • Dead comment utilities. The commentUtils barrel re-exported seven names nothing imports, and the functions behind them were dead too: createOptimisticComment, updateCommentWithApiResponse, mapOptimisticToRealId, getParentId, clearIdMappings, removeCommentDeep, clearAllCommentDrafts, isContentEmpty, getFormattedCommentContent, feedEntryToPostCard, and the useComments hook (useCreateComment in the same file stays).
  • Barrels trimmed to what their importers take: components/Funding and Funding/lib, Nonprofit, Referral, ui/icons, FeatureNotifications. The components only reachable through the removed lines go with them: FundingProposalCard, GrantCard, ProposalCount, FundraiseProgressBar, NonprofitInfoPopover, EndaomentInfoPopover, IllustratedGuide, PaperIcon, and one layer down ProposalPeekView, GrantPreviewTooltip, GrantBadge and usePostContent, which only FundingProposalCard used. RSC_PAYMENT_METHODS and PAYMENT_METHOD_LABELS in Funding/lib/constants.ts had no readers.

32 files changed, 1,848 lines removed, 48 added (the slimmed isProduction, trimmed import lines, and the id renames above). No behaviour change intended.

Second commit: the optimistic-id map

SonarCloud's quality gate on the first commit flagged that optimisticToRealIdMap in commentIdUtils.ts could only ever be empty once mapOptimisticToRealId was gone: getRealId had become an identity function and recordParentChildRelationship filled a map nobody read. Rather than ship a known no-op, the second commit removes commentIdUtils.ts and has the callers in commentTreeUtils, commentOptimisticUtils and CommentContext use the ids they were given. Every removed call either returned its argument or wrote to state nothing consulted, so behaviour is unchanged. The diff there is worth a read since it touches live comment code.

Checks

  • npm run lint: 0 errors (2 pre-existing warnings in untouched files)
  • npm run type-check: clean
  • knip re-run twice (after the first pass and after the second-layer deletions): no unused files, no new unused exports or dependency issues
  • Dev server on the branch: main routes return 200; the funding contribute flow's imports (PaymentStep, StripeProvider, FundingImpactPreview, QuickAmountSelector, the two hooks) are exactly what the trimmed barrel still exports

Next

Chunk 5 (cleanup/5-dead-exports) follows once this is merged.

🤖 Generated with Claude Code

@yattias
yattias requested a review from a team as a code owner October 11, 2026 01:52
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@vercel

vercel Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
web Ready Ready Preview Oct 11, 2026 2:17am UTC

Request Review

yattias and others added 2 commits October 10, 2026 22:16
…rrel-only exports

Fourth chunk of the dead-code plan.

- utils/featureFlags.ts had one flag, hard-coded on, plus a localStorage
  reader nobody called, a console helper installed on window, and DEBUG
  branches that were always off. The two checks in NoteEditorLayout read as
  always-true and are inlined; only isProduction() had readers (the two
  legacy banners), so that is all that remains.
- utils/experiment.ts (the homepage A/B helper) was reachable only through
  an unused import in UserContext.
- The comment-utils barrel re-exported seven names nothing imports, and the
  functions behind them were dead too: createOptimisticComment,
  updateCommentWithApiResponse, mapOptimisticToRealId, getParentId,
  clearIdMappings, removeCommentDeep, clearAllCommentDrafts, isContentEmpty,
  getFormattedCommentContent, feedEntryToPostCard and the unused useComments
  hook (useCreateComment, in the same file, stays).
- Barrels trimmed to what their importers take: components/Funding and
  Funding/lib, Nonprofit, Referral, ui/icons, FeatureNotifications. The
  components only reachable through the removed lines go with them:
  FundingProposalCard, GrantCard, ProposalCount, FundraiseProgressBar,
  NonprofitInfoPopover, EndaomentInfoPopover, IllustratedGuide, PaperIcon,
  and, one layer down, ProposalPeekView, GrantPreviewTooltip, GrantBadge and
  usePostContent, which only FundingProposalCard used. RSC_PAYMENT_METHODS and
  PAYMENT_METHOD_LABELS in Funding/lib/constants had no readers either.

Left for a follow-up: with mapOptimisticToRealId gone nothing writes the
optimistic-id map, so getRealId is now an identity function and
recordParentChildRelationship fills a map nobody reads; simplifying their
callers is a change to live code and belongs in its own review.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
SonarCloud's quality gate on the previous commit pointed out that
optimisticToRealIdMap can only ever be empty once mapOptimisticToRealId is
gone: getRealId had become an identity function and
recordParentChildRelationship filled a map nobody read. Rather than ship a
known no-op, remove commentIdUtils and have the callers in commentTreeUtils,
commentOptimisticUtils and CommentContext use the ids they were given.
Behaviour is unchanged: every removed call either returned its argument or
wrote to state nothing consulted.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@yattias
yattias merged commit 09946e2 into main Oct 11, 2026
4 of 5 checks passed
@yattias
yattias deleted the cleanup/4-flags-and-barrels branch October 11, 2026 02:28

This branch was successfully deployed

1 active deployment
Preview — 15420a31 Deployed Oct 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant