|
| 1 | +# Project coding standards |
| 2 | + |
| 3 | +## Generic Communication Guidelines |
| 4 | + |
| 5 | +- Be succint and be aware that expansive generative AI answers are costly and slow |
| 6 | +- Avoid providing explanations, trying to teach unless asked for, your chat partner is an expert |
| 7 | +- Stop apologising if corrected, just provide the correct information or code |
| 8 | +- Prefer code unless asked for explanation |
| 9 | +- Stop summarizing what you've changed after modifications unless asked for |
| 10 | + |
| 11 | +## TypeScript Guidelines |
| 12 | + |
| 13 | +- Use TypeScript for all new code |
| 14 | +- Where possible, prefer implementations without allocation |
| 15 | +- When there is an option, opt for more performant solutions and trade RAM usage for less CPU cycles |
| 16 | +- Prefer immutable data (const, readonly) |
| 17 | +- Use optional chaining (?.) and nullish coalescing (??) operators |
| 18 | + |
| 19 | +## React Guidelines |
| 20 | + |
| 21 | +- Use functional components with hooks |
| 22 | +- Follow the React hooks rules (no conditional hooks) |
| 23 | +- Keep components small and focused |
| 24 | +- Use CSS modules for component styling |
| 25 | + |
| 26 | +## Naming Conventions |
| 27 | + |
| 28 | +- Use PascalCase for component names, interfaces, and type aliases |
| 29 | +- Use camelCase for variables, functions, and methods |
| 30 | +- Use ALL_CAPS for constants |
| 31 | + |
| 32 | +## Error Handling |
| 33 | + |
| 34 | +- Use try/catch blocks for async operations |
| 35 | +- Implement proper error boundaries in React components |
| 36 | +- Always log errors with contextual information |
| 37 | + |
| 38 | +## Testing |
| 39 | + |
| 40 | +- Always attempt to fix #problems |
| 41 | +- Always offer to run `yarn test:app` in the project root after modifications are complete and attempt fixing the issues reported |
| 42 | + |
| 43 | +## Types |
| 44 | + |
| 45 | +- Always include `packages/math/src/types.ts` in the context when your write math related code and always use the Point type instead of { x, y} |
0 commit comments