Keep related functionality grouped together to improve code discoverability and maintainability. This includes placing related functions in the same module, maintaining consistent test file placement, and avoiding unnecessary file fragmentation.
Keep related functionality grouped together to improve code discoverability and maintainability. This includes placing related functions in the same module, maintaining consistent test file placement, and avoiding unnecessary file fragmentation.
Key practices:
prependBasename
should live in utils.ts
next to stripBasename
)__tests__
directories or always place tests next to implementationinternal-export.ts
live in types/internal-export/
folder)Example of good organization:
// utils.ts - related string manipulation functions together
export function stripBasename(pathname: string, basename: string) { ... }
export function prependBasename(pathname: string, basename: string) { ... }
// Avoid creating separate single-line modules when functionality fits logically elsewhere
// Instead of: types/register.ts with just "export interface Register {}"
// Consider: utils.ts or existing appropriate module
This approach reduces cognitive load when navigating the codebase and makes it easier to find related functionality.
Enter the URL of a public GitHub repository