|
1 |
| -# Project Coding Standards |
| 1 | +# Project Overview |
2 | 2 |
|
3 |
| -**Instructions for all code generation:** |
| 3 | +This is a personal website built with Next.js, TypeScript, and Tailwind CSS. The project is hosted on both Vercel and GitHub Pages. It includes a comprehensive setup for testing, CI/CD, and performance monitoring. |
4 | 4 |
|
5 |
| -- This is a NextJS project. Please adhere to the following coding standards: |
| 5 | +## Building and Running |
6 | 6 |
|
7 |
| -- **Follow Existing Style:** Strictly adhere to the existing coding style, conventions, and file structure. |
8 |
| -- **Component Structure:** Create new components in their own folder (e.g., `src/components/MyComponent/index.tsx`). |
9 |
| -- **No Semicolons:** Do not use semicolons at the end of statements, as per the project's Prettier configuration (`"semi": false`). |
10 |
| -- **ESLint and Prettier:** Ensure all code passes ESLint and Prettier checks. Run `npm run lint` to verify. |
11 |
| -- **No Console Logs:** Avoid using `console.log()` or other console methods. Use a proper logger if needed. |
12 |
| -- **Testing:** Write unit tests for new features using Jest and React Testing Library. Test files should be co-located with the component and named with the pattern `[ComponentName].test.tsx`. To run a single test, use `npm run test:single -- <test_file_path>`. |
13 |
| -- **Code Quality:** Keep the code clean, readable, and well-documented where necessary. |
14 |
| -- **Technology Stack:** This is a Next.js project using TypeScript and Tailwind CSS. |
| 7 | +### Development |
15 | 8 |
|
| 9 | +To run the development server, use the following command: |
| 10 | + |
| 11 | +```bash |
| 12 | +npm run dev |
| 13 | +``` |
| 14 | + |
| 15 | +### Testing |
| 16 | + |
| 17 | +The project uses a multi-layered testing strategy: |
| 18 | + |
| 19 | +* **Unit Tests:** Run unit tests with Jest: |
| 20 | + ```bash |
| 21 | + npm run test:single |
| 22 | + ``` |
| 23 | +* **End-to-End (E2E) Tests:** Run E2E tests with Playwright: |
| 24 | + ```bash |
| 25 | + npm run e2e:test |
| 26 | + ``` |
| 27 | +* **Smoke Tests:** Run smoke tests with Playwright: |
| 28 | + ```bash |
| 29 | + npm run smoke:test |
| 30 | + ``` |
| 31 | +* **Visual Regression Tests:** Use BackstopJS for visual regression testing: |
| 32 | + ```bash |
| 33 | + npm run backstop:test |
| 34 | + npm run backstop:approve |
| 35 | + ``` |
| 36 | + |
| 37 | +### Linting |
| 38 | + |
| 39 | +To check for linting and formatting errors, run: |
| 40 | + |
| 41 | +```bash |
| 42 | +npm run lint |
| 43 | +``` |
| 44 | + |
| 45 | +To automatically fix linting and formatting issues, use: |
| 46 | + |
| 47 | +```bash |
| 48 | +npm run lint:fix |
| 49 | +``` |
| 50 | + |
| 51 | +## Development Conventions |
| 52 | + |
| 53 | +### Code Style |
| 54 | + |
| 55 | +The project uses ESLint and Prettier to enforce a consistent code style. Configuration can be found in `eslint.config.mjs` and `.prettierrc.json`. |
| 56 | + |
| 57 | +Key code style rules: |
| 58 | +* No semicolons. |
| 59 | +* Double quotes for strings. |
| 60 | + |
| 61 | +Folder structure: |
16 | 62 | - `src/app/`: This directory contains all pages and routes for the application. Files here are responsible for data fetching and view composition.
|
17 | 63 | - `src/components/`: This directory holds all reusable React components like buttons, cards, and forms. Components should be stateless unless they need to manage their own UI state.
|
18 | 64 | - `styles/`: This folder contains global CSS files, utility classes, and theming configurations.
|
| 65 | + |
| 66 | +### Dependency Management |
| 67 | + |
| 68 | +The project uses `knip` to check for unused dependencies. Run the following command to check for unused dependencies: |
| 69 | + |
| 70 | +```bash |
| 71 | +npm run dependency:check |
| 72 | +``` |
| 73 | + |
| 74 | +### CI/CD |
| 75 | + |
| 76 | +The project has a CI/CD pipeline configured with GitHub Actions. The pipeline includes steps for: |
| 77 | + |
| 78 | +* Linting and testing |
| 79 | +* Building and deploying to Vercel |
| 80 | +* Generating and deploying a static version to GitHub Pages |
| 81 | +* Running smoke tests after deployment |
| 82 | + |
| 83 | +### Environment Variables |
| 84 | + |
| 85 | +Environment variables are managed using a `.env.local` file. To set up the environment variables, you can use the Vercel CLI to pull them from the Vercel project: |
| 86 | + |
| 87 | +```bash |
| 88 | +vercel env pull .env.local |
| 89 | +``` |
| 90 | + |
| 91 | +### Rust/Wasm Integration |
| 92 | + |
| 93 | +The project includes a Rust-based WebAssembly module for a snake game. To build the Wasm module, run: |
| 94 | + |
| 95 | +```bash |
| 96 | +npm run rust:generate |
| 97 | +``` |
| 98 | + |
| 99 | + |
0 commit comments