Skip to content

Commit 67efa1f

Browse files
committed
Update frontend AI rules to use React form components over HTML to follow conventions
1 parent 7721c50 commit 67efa1f

9 files changed

Lines changed: 43 additions & 19 deletions

.cursor/rules/frontend/form-with-validation.mdc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,18 @@ function BadUserProfileForm({ user }) {
9797
};
9898

9999
return (
100-
<form onSubmit={handleSubmit}>
100+
<Form onSubmit={handleSubmit}>
101101
{/* Missing proper validation and error handling */}
102-
<input name="firstName" defaultValue={user?.firstName} required />
103-
<input name="lastName" defaultValue={user?.lastName} required />
104-
<input name="title" defaultValue={user?.title} />
102+
<TextField name="firstName" defaultValue={user?.firstName} isRequired />
103+
<TextField name="lastName" defaultValue={user?.lastName} isRequired />
104+
<TextField name="title" defaultValue={user?.title} />
105105

106-
{error && <div className="error">{error.message}</div>}
106+
{error && <FormErrorMessage error={error} />}
107107

108-
<button type="submit" disabled={isLoading}>
109-
{isLoading ? "Saving..." : "Save changes"}
110-
</button>
111-
</form>
108+
<Button type="submit" isDisabled={isLoading}>
109+
{isLoading ? <Trans>Saving...</Trans> : <Trans>Save changes</Trans>}
110+
</Button>
111+
</Form>
112112
);
113113
}
114114
```

.cursor/rules/frontend/react-aria-components.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { Form } from "@repo/ui/components/Form";
2525
import { FormErrorMessage } from "@repo/ui/components/FormErrorMessage";
2626
import { Button } from "@repo/ui/components/Button";
2727
import { TextField } from "@repo/ui/components/TextField";
28+
import { Trans } from "@lingui/react/macro";
2829

2930
<Form>
3031
<TextField

.cursor/rules/frontend/tanstack-query-api-integration.mdc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Note: All .NET API endpoints are available as strongly typed API contracts in th
2727
## Example 1 - Data Fetching Example
2828

2929
```typescript
30+
import { LoadingSpinner } from "@repo/ui/components/LoadingSpinner";
31+
import { UserList } from "@repo/ui/components/UserList";
32+
3033
const { data: users, isLoading } = api.useQuery("get", "/api/users", {
3134
params: { query: { Search: search } }
3235
});
@@ -65,6 +68,12 @@ const handleComplete = () => {
6568
## Example 3 - Form Submission Example
6669

6770
```typescript
71+
import { Form } from "@repo/ui/components/Form";
72+
import { FormErrorMessage } from "@repo/ui/components/FormErrorMessage";
73+
import { TextField } from "@repo/ui/components/TextField";
74+
import { Button } from "@repo/ui/components/Button";
75+
import { Trans } from "@lingui/react/macro";
76+
6877
<Form
6978
onSubmit={mutationSubmitter(completeLoginMutation, {
7079
path: { id: loginId }

.cursor/rules/frontend/translations.mdc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Carefully follow these instructions when implementing translations and internati
2222

2323
```tsx
2424
import { Trans } from "@lingui/react/macro";
25+
import { Button } from "@repo/ui/components/Button";
26+
import { Heading } from "@repo/ui/components/Heading";
2527

2628
<Button onPress={handleLogin}>
2729
<Trans>Log in</Trans>

.windsurf/rules/frontend/form-with-validation.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,18 @@ function BadUserProfileForm({ user }) {
9898
};
9999

100100
return (
101-
<form onSubmit={handleSubmit}>
101+
<Form onSubmit={handleSubmit}>
102102
{/* Missing proper validation and error handling */}
103-
<input name="firstName" defaultValue={user?.firstName} required />
104-
<input name="lastName" defaultValue={user?.lastName} required />
105-
<input name="title" defaultValue={user?.title} />
103+
<TextField name="firstName" defaultValue={user?.firstName} isRequired />
104+
<TextField name="lastName" defaultValue={user?.lastName} isRequired />
105+
<TextField name="title" defaultValue={user?.title} />
106106

107-
{error && <div className="error">{error.message}</div>}
107+
{error && <FormErrorMessage error={error} />}
108108

109-
<button type="submit" disabled={isLoading}>
110-
{isLoading ? "Saving..." : "Save changes"}
111-
</button>
112-
</form>
109+
<Button type="submit" isDisabled={isLoading}>
110+
{isLoading ? <Trans>Saving...</Trans> : <Trans>Save changes</Trans>}
111+
</Button>
112+
</Form>
113113
);
114114
}
115115
```

.windsurf/rules/frontend/frontend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Carefully follow these instructions for frontend TypeScript and React developmen
3737
- Reference existing implementations to maintain consistency.
3838

3939
4. Build and format your changes:
40-
- After each minor change, run `[CLI_ALIAS] format --frontend` to format your code. See [Tools](/.windsurf/rules/tools.md) for details.
40+
- After each minor change, run `[CLI_ALIAS] build --frontend` to format your code. See [Tools](/.windsurf/rules/tools.md) for details.
4141
- This ensures consistent code style across the codebase.
4242

4343
5. Verify your changes:

.windsurf/rules/frontend/react-aria-components.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { Form } from "@repo/ui/components/Form";
2626
import { FormErrorMessage } from "@repo/ui/components/FormErrorMessage";
2727
import { Button } from "@repo/ui/components/Button";
2828
import { TextField } from "@repo/ui/components/TextField";
29+
import { Trans } from "@lingui/react/macro";
2930

3031
<Form>
3132
<TextField

.windsurf/rules/frontend/tanstack-query-api-integration.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Note: All .NET API endpoints are available as strongly typed API contracts in th
2828
## Example 1 - Data Fetching Example
2929

3030
```typescript
31+
import { LoadingSpinner } from "@repo/ui/components/LoadingSpinner";
32+
import { UserList } from "@repo/ui/components/UserList";
33+
3134
const { data: users, isLoading } = api.useQuery("get", "/api/users", {
3235
params: { query: { Search: search } }
3336
});
@@ -66,6 +69,12 @@ const handleComplete = () => {
6669
## Example 3 - Form Submission Example
6770

6871
```typescript
72+
import { Form } from "@repo/ui/components/Form";
73+
import { FormErrorMessage } from "@repo/ui/components/FormErrorMessage";
74+
import { TextField } from "@repo/ui/components/TextField";
75+
import { Button } from "@repo/ui/components/Button";
76+
import { Trans } from "@lingui/react/macro";
77+
6978
<Form
7079
onSubmit={mutationSubmitter(completeLoginMutation, {
7180
path: { id: loginId }

.windsurf/rules/frontend/translations.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Carefully follow these instructions when implementing translations and internati
2323

2424
```tsx
2525
import { Trans } from "@lingui/react/macro";
26+
import { Button } from "@repo/ui/components/Button";
27+
import { Heading } from "@repo/ui/components/Heading";
2628

2729
<Button onPress={handleLogin}>
2830
<Trans>Log in</Trans>

0 commit comments

Comments
 (0)