mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
2.0 KiB
2.0 KiB
General
- only rarely use comments, prefer descriptive variable and function names (leave existing comments as is)
- if you encounter an existing TODO comment assume it is there for a reason and do not remove it
Commands
npm run typecheckruns TypeScript type checkingnpm run biome:fixruns Biome code formatter and linternpm run test:unitruns all unit testsnpm run i18n:syncsyncs translation jsons with English and should always be run after adding new text to an English translation file
Typescript
- prefer early return over nesting if statements
- do not use
anytype - for constants use ALL_CAPS
- always use named exports
- Remeda is the utility library of choice
React
- prefer functional components over class components
- prefer using hooks over class lifecycle methods
- do not use
useMemo,useCallbackoruseReducerat all - state management is done via plain
useStateand React Context API - avoid using
useEffect - split bigger components into smaller ones
- one file can have many components
- all texts should be provided translations via the i18next library's
useTranslationshook'stfunction - instead of
&&operator for conditional rendering, use the ternary operator
Styling
- use CSS modules
- one file containing React code should have a matching CSS module file e.g.
Component.tsxshould have a file with the same root name i.e.Component.module.css - clsx library is used for conditional class names
- prefer using CSS variables for theming
SQL
- database is Sqlite3 used with the Kysely library
- database code should only be written in Repository files
- down migrations are not needed, only up migrations
- every database id is of type number
E2E testing
- library used for E2E testing is Playwright
page.gotois forbidden, use thenavigatefunction to do a page navigation- to submit a form you use the
submitfunction
Unit testing
- library used for unit testing is Vitest