Skip to content

Commit 86722ef

Browse files
authored
Merge branch 'main' into 185-user_role-ui-updates
2 parents 465ab00 + 841bf18 commit 86722ef

File tree

18 files changed

+1416
-287
lines changed

18 files changed

+1416
-287
lines changed

.claude/CLAUDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# refactor-platform-fe Project Instructions
2+
3+
## Mandatory File Consultations
4+
5+
**Code Implementation/Editing** → Read `.claude/coding-standards.md` FIRST
6+
**Pull Request Operations** → Read `.claude/pr-instructions.md` FIRST
7+
8+
## Rules
9+
- Project standards override global defaults on conflict
10+
- Validate all code against standards before task completion
11+
- PR reviews require both files if coding standards referenced

.claude/coding-standards.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Coding Standards
2+
3+
This document outlines coding conventions and standards for this project.
4+
5+
## React and TypeScript
6+
7+
### Import Conventions
8+
9+
**React Imports**: Always import specific hooks and types from React rather than using the `React.` prefix.
10+
11+
```typescript
12+
// ✅ Correct
13+
import { useState, useEffect, useCallback } from "react";
14+
import type { FC, ReactNode } from "react";
15+
16+
export const MyComponent: FC = () => {
17+
const [count, setCount] = useState(0);
18+
19+
useEffect(() => {
20+
// effect logic
21+
}, []);
22+
23+
return <div>{count}</div>;
24+
};
25+
26+
// ❌ Incorrect
27+
import React from "react";
28+
29+
export const MyComponent: React.FC = () => {
30+
const [count, setCount] = React.useState(0);
31+
32+
React.useEffect(() => {
33+
// effect logic
34+
}, []);
35+
36+
return <div>{count}</div>;
37+
};
38+
```
39+
40+
**Rationale**:
41+
- Improves code readability by making hook usage more explicit
42+
- Reduces verbosity and visual clutter
43+
- Aligns with modern React conventions and tree-shaking optimization
44+
- Consistent with the rest of the codebase
45+
46+
### Type Annotations
47+
48+
- Use explicit function component typing sparingly - TypeScript can often infer the type
49+
- When needed, import `FC` or `ReactNode` types explicitly from React
50+
- Prefer explicit return types for component props interfaces
51+
52+
```typescript
53+
// ✅ Good - TypeScript infers the component type
54+
export const SimpleComponent = () => {
55+
return <div>Hello</div>;
56+
};
57+
58+
// ✅ Good - explicit typing when needed for props
59+
import type { FC, ReactNode } from "react";
60+
61+
interface Props {
62+
children: ReactNode;
63+
title: string;
64+
}
65+
66+
export const ComplexComponent: FC<Props> = ({ children, title }) => {
67+
return <div>{title}{children}</div>;
68+
};
69+
```
70+
71+
## General Guidelines
72+
73+
### Naming Conventions
74+
- Use PascalCase for component names and files: `ConnectionStatus.tsx`
75+
- Use PascalCase for enum types: `ConnectionState`, `BadgeVariant`
76+
- Use PascalCase for enum values: `ConnectionState.Connecting`, `BadgeVariant.Secondary`
77+
- Use camelCase for functions, variables, and hooks: `useEditorCache`, `handleClick`
78+
- Use SCREAMING_SNAKE_CASE for constants: `MAX_RETRIES`, `API_ENDPOINT`
79+
80+
```typescript
81+
// ✅ Correct - PascalCase for enum types and values
82+
enum ConnectionState {
83+
Connecting = "connecting",
84+
Connected = "connected",
85+
Offline = "offline",
86+
Error = "error",
87+
}
88+
89+
// ❌ Incorrect - lowercase or SCREAMING_SNAKE_CASE
90+
enum connectionState {
91+
CONNECTING = "connecting",
92+
CONNECTED = "connected",
93+
}
94+
```
95+
96+
### File Organization
97+
- Keep React components in `src/components/`
98+
- Place tests in `__tests__/` directories mirroring the source structure
99+
- Group related components in feature-specific subdirectories
100+
101+
### Documentation
102+
- Add JSDoc comments for complex logic or non-obvious patterns
103+
- Explain *why* something is done, not just *what* is being done
104+
- Document external state synchronization patterns (like forceUpdate mechanisms)
105+
106+
## Code Review Checklist
107+
108+
When reviewing or writing code, ensure:
109+
- [ ] React hooks are imported directly, not accessed via `React.`
110+
- [ ] Components follow the established import patterns
111+
- [ ] Enum types and values use PascalCase
112+
- [ ] Complex logic has explanatory comments
113+
- [ ] Tests are updated to match code changes
114+
- [ ] TypeScript types are properly defined and used

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@ npm run test:e2e
117117

118118
### Test Structure
119119

120-
- **`__tests__/`** - Unit and integration tests
121-
- `stores/` - State management logic tests
122-
- `hooks/` - React hooks integration tests
123-
- `components/` - UI component tests
124-
- **`e2e/`** - End-to-end browser tests
120+
- **`__tests__/`** - Unit, integration, and E2E tests (mirrors `src/` structure)
121+
- `components/ui/` - UI component tests (mirrors `src/components/ui/`)
122+
- `lib/stores/` - State management logic tests (mirrors `src/lib/stores/`)
123+
- `lib/hooks/` - React hooks integration tests (mirrors `src/lib/hooks/`)
125124
- **`src/test-utils/`** - Testing utilities and mocks
126125

126+
**Note**: E2E tests (`.spec.ts` files) are now organized alongside unit tests in the `__tests__/` directory, mirroring the source code structure for easier navigation and maintenance.
127+
127128
### Debugging Tests
128129

129130
If tests fail, you can:

0 commit comments

Comments
 (0)