What problem does it solve?
Patterns for splitting functions and components into their own files while ensuring consistent exports, JSDoc preservation, and test colocation. This guide helps teams decompose large files into focused modules to improve maintainability, reuse, and clarity across a codebase.
Core Features & Use Cases
- One function per file by default to promote focused, reusable units.
- Single symbol exports: use default export for single-symbol files; support multi-symbol files with named exports when necessary.
- Naming conventions: name files after the symbol for single-symbol files; use kebab-case for multi-symbol files that export multiple symbols.
- JSDoc preservation: carry over existing documentation and comments during refactoring.
- Test colocations: move and colocate tests next to the new source file.
- Import management: update all references to moved symbols across the codebase.
Quick Start
Identify a candidate function or component to extract, create a new file named after the symbol, and move its tests beside the new source file.