|
| 1 | +- Always use the latest version of TypeScript, React, and Next.js |
| 2 | +- Sentence case headers and buttons and stuff, not title case |
| 3 | +- Always write ALL of the code |
| 4 | +- Don't apologize for errors, fix them |
| 5 | +- Newlines at end of files, always |
| 6 | + |
| 7 | +- To add a feature: |
| 8 | + - Add page to `frontend/app/**/page.tsx` |
| 9 | + - Add any components to `frontend/components/**/*.tsx` |
| 10 | + - Add tRPC API routes to `frontend/trpc/routes/**/index.ts` and then add those to `frontend/trpc/server.ts` |
| 11 | + - Create API handlers using tRPC API routes that follow REST principles |
| 12 | + - Forms for adding new objects to the database should inherit values from the last object added to the table (e.g., contractor forms should default to the last contractor's values like contractSignedElsewhere, payRateInSubunits, role, etc.) |
| 13 | + |
| 14 | +- For writing end-to-end tests: |
| 15 | + - Use Playwright tests in `e2e/**/*.spec.ts` |
| 16 | + - If migrating from rspec, delete the rspec tests |
| 17 | + - Factories can be created using the rspec factories in `spec/factories` in the `/e2e/factories` folder |
| 18 | + - For any broken locators / assertions, you can use the playwright extension to record tests or pick locators |
| 19 | + |
| 20 | +- For writing front-end code: |
| 21 | + - Do not use `React.FC`. Use the following syntax: `const Component = ({ prop1, prop2 }: { prop1: string; prop2: number }) => { ... }` |
| 22 | + |
| 23 | +- After any functional code change: |
| 24 | + - For Ruby/Rails changes: |
| 25 | + - Add or update unit tests in `backend/spec/models/` for model changes |
| 26 | + - Add or update controller tests in `backend/spec/controllers/` for controller changes |
| 27 | + - Add or update system tests in `backend/spec/system/` for UI flow changes |
| 28 | + - Run tests with `bundle exec rspec <path_to_spec>` to verify |
| 29 | + - For TypeScript/Next.js changes: |
| 30 | + - Add or update unit tests for front-end business logic |
| 31 | + - Add or update e2e tests in `e2e/tests/` that cover the changed functionality |
| 32 | + - Follow the existing test patterns in similar files |
| 33 | + - Run tests with `pnpm playwright test <path_to_spec>` to verify e2e tests |
| 34 | + - Tests should cover: |
| 35 | + - Happy path (expected behavior) |
| 36 | + - Edge cases and error handling |
| 37 | + - Any regressions that might be introduced |
| 38 | + |
| 39 | +- Tech debt: |
| 40 | + - Add a `TODO (techdebt)` comment to document refactors that should be made in the future |
| 41 | + |
| 42 | +- No explanatory comments please |
| 43 | + |
| 44 | +- When adding new rules: Always update both `.cursorrules` and `.github/copilot-instructions.md` to keep them synchronized |
0 commit comments