Compare commits

...

1 Commits

Author SHA1 Message Date
user
97f5d8a91f styleguide: add rule against type-only packages
Types should be defined alongside the implementations that use them,
not in separate 'types' or 'domain' packages. This avoids awkward
import aliases and keeps types close to their usage.
2026-02-23 11:47:34 -08:00

View File

@ -227,6 +227,14 @@ last_modified: 2026-02-22
}
```
1. Do not create packages just to hold types (e.g. `types`, `domain`,
`models` that contain only type definitions). Define types alongside the
implementations that use them. A type-only package is a sign that the types
are in the wrong place — move them to the package that actually operates on
them. This also avoids awkward import aliases (e.g.
`domaintypes "myapp/internal/domain"`) which are a code smell indicating
poor package naming.
1. Define your struct types near their constructors.
1. Define your interface types near the functions that use them, or if you have