forked from sneak/prompts
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.
This commit is contained in:
parent
189e54862e
commit
97f5d8a91f
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user