Skip to content

Refactor: code structure and dev environment standardization#38

Merged
hackerwins merged 3 commits into
mainfrom
refactor/code-structure-and-dev-env
Mar 15, 2026
Merged

Refactor: code structure and dev environment standardization#38
hackerwins merged 3 commits into
mainfrom
refactor/code-structure-and-dev-env

Conversation

@hackerwins

@hackerwins hackerwins commented Mar 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Unify TypeScript versions: Align all packages to ^5.9.3 (was mixed 5.5–5.8)
  • Standardize Prettier config: Create root .prettierrc, remove per-package overrides
  • Tighten backend tsconfig: Add noUnusedLocals, noUnusedParameters, clean up dead code
  • Remove unused backend dependency: @tanstack/react-query (never imported)
  • Split formula functions: Monolithic file (16K lines, 438 functions) → 10 category modules
  • Extract Sheet class helpers: Move pure computation functions into filter, clipboard, style-mutation modules (~480 lines reduced)

Details

Dev Environment Standardization

Item Before After
TypeScript Mixed 5.5–5.9 ^5.9.3 unified
Prettier Per-package duplicates Single root .prettierrc
Backend tsconfig Loose settings noUnusedLocals + noUnusedParameters
Backend deps Included @tanstack/react-query Removed

Code Structure

Item Before After
functions.ts 15,968-line monolith 27-line hub + 10 category modules
sheet.ts ~4,058 lines ~3,581 lines (3 modules extracted)

New modules created:

  • functions-{math,statistical,text,lookup,date,logical,financial,engineering,database,info}.ts
  • model/worksheet/{filter,clipboard,style-mutation}.ts

All changes are pure refactoring with no logic modifications.

Test plan

  • pnpm verify:fast passes (lint + architecture + all tests)
  • Sheet package: 50 files, 1018 tests passing
  • Backend: 11 files, 103 tests passing
  • Frontend: 51 tests passing
  • CLI: 6 files, 59 tests passing
  • TypeScript typecheck clean across all packages

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added comprehensive suite of spreadsheet formula functions including database operations (DSUM, DCOUNT, DAVERAGE, etc.), date/time functions (TODAY, DATE, WEEKDAY, NETWORKDAYS, etc.), financial calculations (PMT, FV, PV, IRR, NPV, etc.), mathematical and trigonometric functions, text manipulation, logical operations, lookup capabilities (VLOOKUP, XLOOKUP, MATCH, INDEX), engineering utilities (complex numbers, base conversions, unit conversion), and information functions.
  • Chores

    • Upgraded TypeScript to 5.9.3 across all packages.
    • Removed unused dependencies and code.
    • Enabled stricter TypeScript compiler checks.

hackerwins and others added 3 commits March 15, 2026 21:08
Align all packages to TypeScript ^5.9.3 (was mixed 5.5-5.8).
Move Prettier config to root .prettierrc, remove per-package overrides.
Add noUnusedLocals/noUnusedParameters to backend tsconfig.
Remove unused @tanstack/react-query from backend dependencies.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Move pure computation functions from Sheet class into filter.ts,
clipboard.ts, and style-mutation.ts following the existing module
pattern (merging.ts, shifting.ts). Sheet class keeps state ownership
and store access, delegates computation to extracted functions.
No logic changes.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@coderabbitai

coderabbitai Bot commented Mar 15, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Backend packages undergo cleanup including removing unused code, updating TypeScript to 5.9.3, and enabling stricter compiler checks. The sheet package expands significantly with comprehensive Excel-compatible formula implementations (12+ function categories covering database, date, engineering, financial, logical, lookup, math, text operations) and refactors worksheet operations into shared utility modules for clipboard, filtering, and style mutations.

Changes

Cohort / File(s) Summary
Backend Config & Cleanup
packages/backend/.prettierrc, packages/backend/src/api/v1/cells.controller.ts, packages/backend/src/auth/github.strategy.ts, packages/backend/src/auth/jwt.strategy.ts, packages/backend/src/datasource/crypto.util.ts, packages/backend/src/document/document.controller.ts, packages/backend/src/yorkie/worksheet-shape-migration.spec.ts
Removed Prettier config, eliminated unused imports, renamed unused parameters with underscore prefix, removed unused class member (configService in JwtStrategy), removed ConfigService from DocumentController constructor, and removed unused crypto constant.
TypeScript & Dependency Updates
packages/backend/package.json, packages/backend/tsconfig.json, packages/cli/package.json, packages/frontend/package.json, packages/sheet/package.json
Bumped TypeScript version from 5.7.3–5.8.3 to 5.9.3 across all packages; removed @tanstack/react-query dependency from backend; added noUnusedLocals and noUnusedParameters compiler options to backend tsconfig.
Sheet Formula: Database & Date Functions
packages/sheet/src/formula/functions-database.ts, packages/sheet/src/formula/functions-date.ts
Introduced 12 database functions (DSUM, DCOUNT, DCOUNTA, DAVERAGE, DMAX, DMIN, DPRODUCT, DGET, DSTDEV, DSTDEVP, DVAR, DVARP) with criteria extraction; added 25+ date/time functions (TODAY, NOW, DATE, TIME, EDATE, EOMONTH, NETWORKDAYS, DATEVALUE, YEARFRAC, etc.) with multiple basis and weekend conventions.
Sheet Formula: Engineering & Financial Functions
packages/sheet/src/formula/functions-engineering.ts, packages/sheet/src/formula/functions-financial.ts
Engineering: 50+ functions covering unit conversion, bitwise ops, base conversions, complex arithmetic, and Bessel functions. Financial: 50+ functions for cash flow, amortization, bonds, coupons, rates (PMT, FV, PV, NPV, XIRR, DURATION, PRICE, YIELD, etc.).
Sheet Formula: Info, Logical & Lookup Functions
packages/sheet/src/formula/functions-info.ts, packages/sheet/src/formula/functions-logical.ts, packages/sheet/src/formula/functions-lookup.ts
Info: ISBLANK, ISNUMBER, ISTEXT, ISERROR, ISFORMULA, CELL, SHEET (22 functions). Logical: IF, IFS, SWITCH, AND, OR, NOT, XOR, CHOOSE, IFERROR, IFNA. Lookup: 35+ functions including MATCH, INDEX, VLOOKUP, XLOOKUP, FILTER, SORT, TRANSPOSE, HSTACK, VSTACK, etc.
Sheet Formula: Math & Text Functions
packages/sheet/src/formula/functions-math.ts, packages/sheet/src/formula/functions-text.ts
Math: 80+ functions covering trig, hyperbolic, logarithmic, statistical, matrix operations (MMULT, MINVERSE), combinatorics (COMBIN, PERMUT), and special functions. Text: 40+ functions for string manipulation, regex matching/replacement, Unicode handling, case conversion, splitting, and formatting.
Sheet Formula Helpers
packages/sheet/src/formula/functions-helpers.ts
New utilities module providing criterion parsing, reference/matrix extraction, lookup-value normalization, wildcard-to-regex conversion, and error-handling primitives shared across formula implementations.
Sheet Worksheet Utilities
packages/sheet/src/model/worksheet/clipboard.ts, packages/sheet/src/model/worksheet/filter.ts, packages/sheet/src/model/worksheet/style-mutation.ts
Clipboard: reference relocation and cell cloning for copy/cut/paste/autofill. Filter: text normalization, condition matching, boundary shifting, and filter state serialization. Style: cell content checks, range intersection, style patch merging/pruning, and border preset conversion.
Sheet Core Refactoring
packages/sheet/src/model/worksheet/sheet.ts
Internal refactoring to import and delegate to new shared utilities (filter, clipboard, style-mutation) replacing inline implementations; no public API changes but 477 lines removed and logic reorganized.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 A bunny hops through formula lands,
Adding SUM, DATE, with nimble hands—
Database, math, and text unite,
Refactored sheets shine clean and bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary focus of the changeset: refactoring code structure and standardizing the development environment across packages.
Docstring Coverage ✅ Passed Docstring coverage is 94.52% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/code-structure-and-dev-env
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Verification: verify:self

Result: ✅ PASS in 94.2s

Lane Status Duration
sheet:build ✅ pass 12.7s
verify:fast ✅ pass 46.9s
frontend:build ✅ pass 13.8s
verify:frontend:chunks ✅ pass 0.3s
backend:build ✅ pass 4.4s
cli:build ✅ pass 1.8s
verify:entropy ✅ pass 14.3s

Verification: verify:integration

Result: ✅ PASS

@hackerwins
hackerwins merged commit e6f530a into main Mar 15, 2026
3 checks passed
@hackerwins
hackerwins deleted the refactor/code-structure-and-dev-env branch March 15, 2026 12:43
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