Instruction file imported from bartstc/vite-ts-react-template (
.github/instructions/code-style.instructions.md). Copyright stays with the author.
Code Style
File Naming
| Category | Convention | Example |
|---|---|---|
| React components | PascalCase | ProductCard.tsx, SignInForm.tsx |
| Storybook stories | PascalCase | ProductCard.stories.tsx |
| Page Objects (E2E) | PascalCase | ProductListPage.ts |
| Everything else | kebab-case | auth-store.ts, use-counter.ts |
Test files mirror source: use-counter.ts → use-counter.test.ts.
File names match the primary export when possible: ProductCard.tsx exports ProductCard component, use-add-product.ts exports useAddProduct hook.
TypeScript
- Use
unknowninstead ofany— refactor or use type guards instead of type assertions (as Type) - Prefer solving problems with TypeScript types over runtime code when possible
- Use named exports exclusively
React
- Split complex
useEffectinto smaller, focused effects - Prefer composition with
childrenprop over prop drilling - Extract business logic to custom hooks or functions — keep components presentational
General
- Prefer immutability and pure functions — return new objects/arrays instead of mutating
- Follow lint/style configs (
.prettierrc,.eslint.config.mjs) — do not reformat to any other style