Project stylistic refactoring rules for TypeScript/Bun. Proactively scans for refactoring opportunities and produces a prioritized plan. Defines the team's preferred coding style.
Scan the codebase for opportunities to apply these stylistic preferences. Each style has a reference file with rationale, examples, and exceptions.
| Style | Rule (one line) | Reference |
|---|---|---|
| Early Returns | Prefer early returns and guard clauses over nested conditionals | details |
| Classes vs Functions | Classes for stateful coordinators; plain functions for pure logic | details |
| Arrow vs Declaration | Arrow functions for callbacks/inline; function declarations for named exports | details |
| Explicit Return Types | Exported functions must have explicit return type annotations | details |
| Descriptive Naming | Boolean prefixes (is/has/should/can); descriptive names over abbreviations | details |
| Function Size | Functions should stay under ~50 lines; extract when logic is a named concept | details |
| Composition over Inheritance | Flat interface implementations; no deep class hierarchies; share via helpers | details |
Write the refactoring plan to docs/stylistic-refactor-plan.md.
The document should be a prioritized refactoring plan with these sections:
Implement-ready refactors with current/target code, file paths, and acceptance criteria.
Valid refactors with moderate impact. Brief entries with file paths and rationale.
Code that technically violates a style but should NOT be refactored, with justification.