@@ -37,23 +37,57 @@ When writing database models:
3737* Use single double-quote docstrings (a string below the field definition) instead of comments to describe a field's purpose.
3838* Use ` ModelName.foreign_key() ` when generating a foreign key field
3939
40+ ## TypeScript
41+
42+ - Use ` pnpm ` , not ` npm `
43+ - Node libraries are not available
44+ - Use ` lib/ ` for generic code, ` utils/ ` for project utilities, ` hooks/ ` for React hooks, and ` helpers/ ` for page-specific helpers.
45+
4046## React
4147
42- 1 . Do not write any backend code. Just frontend logic.
43- 2 . For any backend requirements, create mock responses. Use a function to return mock data so I can easily swap it out later.
44- 3 . When creating mock data, always specify it in a dedicated ` mock.ts ` file
45- 4 . Load mock data using a react router ` clientLoader ` . Use the Skeleton component to present a loading state.
46- 5 . Store components for each major page or workflow in ` src/components/$WORKFLOW_OR_PAGE_NAME ` .
47- 6 . Use lowercase dash separated words for file names.
48- 8 . Use React 19, TypeScript, Tailwind CSS, and ShadCN components.
49- 9 . Prefer functional components, hooks over classes.
50- 10 . Break up large components into smaller components, but keep them in the same file unless they can be generalized.
51- 11 . Put any "magic" strings like API keys, hosts, etc into a "constants.ts" file.
52- 12 . Only use a separate interface for component props if there are more than 4 props.
53- 13 . Internally, store all currency values as integers and convert them to floats when rendering visually
54- 14 . use ` pnpm ` not ` npm `
55- 15 . Node libraries are not available
56- 16 . Never edit the ` components/ui/*.tsx ` files
48+ - Do not write any backend code. Just frontend logic.
49+ - For any backend requirements, create mock responses. Use a function to return mock data so I can easily swap it out later.
50+ - When creating mock data, always specify it in a dedicated ` mock.ts ` file
51+ - Load mock data using a react router ` clientLoader ` . Use the Skeleton component to present a loading state.
52+ - If a complex skeleton is needed, create a component function ` LoadingSkeleton ` in the same file.
53+ - Store components for each major page or workflow in ` src/components/$WORKFLOW_OR_PAGE_NAME ` .
54+ - Use lowercase dash separated words for file names.
55+ - Use React 19, TypeScript, Tailwind CSS, and ShadCN components.
56+ - Prefer functional components, hooks over classes.
57+ - Break up large components into smaller components, but keep them in the same file unless they can be generalized.
58+ - Put any "magic" strings like API keys, hosts, etc into a "constants.ts" file.
59+ - Only use a separate interface for component props if there are more than 4 props.
60+ - Internally, store all currency values as integers and convert them to floats when rendering visually
61+ - Never edit the ` components/ui/*.tsx ` files
62+ - When building forms use React Hook Form.
63+ - Include a two line breaks between any ` useHook() ` calls and any ` useState() ` definitions for a component.
64+
65+ ## React Hook Form
66+
67+ Follow this structure when generating a form.
68+
69+ ``` react
70+ const formSchema = z.object({
71+ field_name: z.string(),
72+ })
73+
74+ const form = useForm<z.infer<typeof formSchema>>({
75+ resolver: zodResolver(formSchema),
76+ })
77+
78+ async function onSubmit(values: z.infer<typeof formSchema>) {
79+ // ...
80+ }
81+
82+
83+ return (
84+ <Form {...form}>
85+ <form onSubmit={form.handleSubmit(onSubmit)}>
86+ {/* ... */}
87+ </form>
88+ </Form>
89+ )
90+ ```
5791
5892## Shell
5993
0 commit comments