Skip to content

refactor: enforce highest coding standards across th4dev source - #2

Draft
ak4dev with Copilot wants to merge 3 commits into
masterfrom
copilot/refactor-code-to-highest-standards
Draft

refactor: enforce highest coding standards across th4dev source#2
ak4dev with Copilot wants to merge 3 commits into
masterfrom
copilot/refactor-code-to-highest-standards

Conversation

Copilot AI commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Full audit and cleanup of the codebase — remove dead code, fix two silent bugs, and replace every magic number and repeated inline style with named abstractions.

Dead code removed

  • src/index.tsx — orphaned second entry point (index.html always boots main.tsx)
  • src/global.ts — duplicate globalStyles; canonical version is in stitches.config.ts
  • src/App.css / src/index.css — leftover Vite scaffold, never imported
  • src/components/ThemePopover.tsx / sidebar/theme-button.tsx — unused alternative theme UIs, never imported

Bugs fixed

State key mismatch (App.tsx): default sliders initialised yearlyInflationA / yearlyInflationB, but the component exclusively reads/writes yearlyInflation. The inflation slider silently fell back to the hard-coded 2.5 on every load, and the value was dropped on state export/import.

Invalid active-state style (ThemeSwitcher.tsx): active theme button used style={{ backgroundColor: "$purple" }} — Stitches token strings are not valid CSS and the browser received the literal text $purple. Replaced with a Stitches active variant so the CSS variable is resolved at build time.

Code quality

  • App.tsx: removed redundant globalStyles() useEffect (already called in main.tsx before first render).
  • main.tsx: modernised to { StrictMode } named import.
  • InvestmentCalculatorModern.tsx:
    • All hard-coded slider limits (30, 100, 5000, 10000, 10) and default fallbacks (10, 30, 2.5) replaced with named constants from app-constants.
    • Removed two no-op getGrowthMatrix() calls that ran before calculateGrowth() populated the matrix.
    • Three identical style={{ display:"flex", gap:"12px", alignItems:"center" }} inline objects extracted into a SwitchRow styled component.
    • investmentToRoll off-state and setYearContributionsStop fallback use explicit 0 rather than MIN_VALUE — the zero here carries semantic meaning ("no rollover" / "never stop contributions"), not a slider constraint.
  • date-amount-table.tsx: replaced unstable array-index key={idx} with stable key={year}.
Original prompt

Thoroughly evaluate the entire project. After understanding the purpose of everything, refactor such that all of the highest coding standards are enforced. It is imperative that all existing functionality be kept in tact.

Created from VS Code.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI self-assigned this Mar 14, 2026
Copilot AI and others added 2 commits March 14, 2026 11:20
Co-authored-by: ak4dev <92195328+ak4dev@users.noreply.github.com>
Co-authored-by: ak4dev <92195328+ak4dev@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor code for improved standards and functionality refactor: enforce highest coding standards across th4dev source Mar 14, 2026
Copilot AI requested a review from ak4dev March 14, 2026 11:27
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.

2 participants