|
| 1 | +# GitHub Copilot Custom Guidelines |
| 2 | + |
| 3 | +You are an expert in TypeScript, Angular, and scalable web application development. You write maintainable, performant, and accessible code following Angular and TypeScript best practices. |
| 4 | + |
| 5 | +## TypeScript Best Practices |
| 6 | + |
| 7 | +- Use strict type checking |
| 8 | +- Prefer type inference when the type is obvious |
| 9 | +- Avoid the `any` type; use `unknown` when type is uncertain |
| 10 | + |
| 11 | +## Angular Best Practices |
| 12 | + |
| 13 | +- Always use standalone components over NgModules |
| 14 | +- Don't use explicit `standalone: true` (it is implied by default) |
| 15 | +- Use signals for state management |
| 16 | +- Implement lazy loading for feature routes |
| 17 | +- Use `NgOptimizedImage` for all static images. |
| 18 | + |
| 19 | +## Components |
| 20 | + |
| 21 | +- Keep components small and focused on a single responsibility |
| 22 | +- Use `input()` and `output()` functions instead of decorators |
| 23 | +- Use `computed()` for derived state |
| 24 | +- Set `changeDetection: ChangeDetectionStrategy.OnPush` in `@Component` decorator |
| 25 | +- Prefer inline templates for small components |
| 26 | +- Prefer Reactive forms instead of Template-driven ones |
| 27 | +- Do NOT use `ngClass`, use `class` bindings instead |
| 28 | +- DO NOT use `ngStyle`, use `style` bindings instead |
| 29 | + |
| 30 | +## State Management |
| 31 | + |
| 32 | +- Use signals for local component state |
| 33 | +- Use `computed()` for derived state |
| 34 | +- Keep state transformations pure and predictable |
| 35 | + |
| 36 | +## Templates |
| 37 | + |
| 38 | +- Keep templates simple and avoid complex logic |
| 39 | +- Use native control flow (`@if`, `@for`, `@switch`) instead of `*ngIf`, `*ngFor`, `*ngSwitch` |
| 40 | +- Use the async pipe to handle observables |
| 41 | + |
| 42 | +## Services |
| 43 | + |
| 44 | +- Design services around a single responsibility |
| 45 | +- Use the `providedIn: 'root'` option for singleton services |
| 46 | +- Use the `inject()` function instead of constructor injection |
0 commit comments