docs: add interface depth and reuse rules to AGENTS.md

This commit is contained in:
Alan Buscaglia
2025-12-18 13:20:04 +01:00
parent 0c771e3320
commit b151d97793

View File

@@ -13,6 +13,32 @@
- ALWAYS: `const X = { A: "a", B: "b" } as const; type T = typeof X[keyof typeof X]` - ALWAYS: `const X = { A: "a", B: "b" } as const; type T = typeof X[keyof typeof X]`
- NEVER: `type T = "a" | "b"` - NEVER: `type T = "a" | "b"`
### Interfaces
- ALWAYS: One level depth only; object property → dedicated interface (recursive)
- ALWAYS: Reuse via `extends`
- NEVER: Inline nested objects
```typescript
// ✅ CORRECT
interface UserAddress {
street: string;
city: string;
}
interface User {
id: string;
address: UserAddress;
}
interface Admin extends User {
permissions: string[];
}
// ❌ WRONG
interface User {
address: { street: string; city: string };
}
```
### Styling ### Styling
- Single class: `className="bg-slate-800 text-white"` - Single class: `className="bg-slate-800 text-white"`