.cursorrules for a React and TypeScript project
Cursor project rules that pin the stack, the component conventions and the boundaries. Generated code then matches what is in your repository and not a generic React example.
# Stack
React 18, TypeScript strict mode, Vite. Do not suggest Next.js-specific APIs - this is not a Next.js project.
# Components
Function components only, no class components. Props typed with an explicit interface, not inline object types. One component per file, file name matches the component name.
# State
Local state with useState/useReducer. Do not introduce a new state management library without being asked - this project deliberately does not use Redux or similar.
# Styling
Tailwind utility classes only. Do not write new CSS files or styled-components.
# Boundaries
Do not modify anything under /src/generated - it is produced by a codegen step and will be overwritten.
Do not add new dependencies to package.json without flagging it first; list what you would add and why instead of editing the file directly.
# Tests
Co-locate as Component.test.tsx next to Component.tsx. Use React Testing Library, query by role or label text, not by test id, unless no accessible query exists.Notes from the author
The line about /src/generated is there because a generator overwriting a manual fix is worse than the assistant never making it. State the file boundary outright. A comment at the top of the file does not count.
For information only, not professional advice. You use it at your own risk and we are not liable for any loss or damage. See the disclaimer.
Tagged