@su-record/vibe 2.4.72 → 2.4.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +216 -215
- package/README.md +4 -4
- package/agents/research/best-practices-agent.md +13 -13
- package/agents/research/codebase-patterns-agent.md +33 -33
- package/agents/research/framework-docs-agent.md +23 -23
- package/agents/research/security-advisory-agent.md +29 -29
- package/agents/review/architecture-reviewer.md +31 -31
- package/agents/review/complexity-reviewer.md +21 -21
- package/agents/review/data-integrity-reviewer.md +29 -29
- package/agents/review/git-history-reviewer.md +24 -24
- package/agents/review/performance-reviewer.md +29 -29
- package/agents/review/python-reviewer.md +53 -53
- package/agents/review/rails-reviewer.md +40 -40
- package/agents/review/react-reviewer.md +40 -40
- package/agents/review/security-reviewer.md +29 -29
- package/agents/review/simplicity-reviewer.md +24 -24
- package/agents/review/test-coverage-reviewer.md +31 -31
- package/agents/review/typescript-reviewer.md +41 -41
- package/commands/vibe.analyze.md +103 -7
- package/commands/vibe.reason.md +106 -0
- package/commands/vibe.review.md +123 -38
- package/commands/vibe.run.md +286 -223
- package/commands/vibe.spec.md +425 -186
- package/commands/vibe.utils.md +104 -3
- package/commands/vibe.verify.md +179 -86
- package/dist/cli/detect.js +40 -40
- package/dist/cli/detect.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/llm.js +5 -5
- package/dist/cli/llm.js.map +1 -1
- package/dist/cli/setup.js +3 -3
- package/dist/cli/setup.js.map +1 -1
- package/dist/lib/ContextCompressor.js +1 -1
- package/dist/lib/ContextCompressor.js.map +1 -1
- package/dist/lib/MemoryManager.d.ts +13 -155
- package/dist/lib/MemoryManager.d.ts.map +1 -1
- package/dist/lib/MemoryManager.js +52 -617
- package/dist/lib/MemoryManager.js.map +1 -1
- package/dist/lib/gemini-api.js +12 -12
- package/dist/lib/gemini-api.js.map +1 -1
- package/dist/lib/gemini-oauth.js +22 -22
- package/dist/lib/gemini-oauth.js.map +1 -1
- package/dist/lib/gemini-storage.js +3 -3
- package/dist/lib/gemini-storage.js.map +1 -1
- package/dist/lib/gpt-api.js +11 -11
- package/dist/lib/gpt-api.js.map +1 -1
- package/dist/lib/gpt-oauth.js +28 -28
- package/dist/lib/gpt-oauth.js.map +1 -1
- package/dist/lib/gpt-storage.js +3 -3
- package/dist/lib/gpt-storage.js.map +1 -1
- package/dist/lib/memory/KnowledgeGraph.d.ts +34 -0
- package/dist/lib/memory/KnowledgeGraph.d.ts.map +1 -0
- package/dist/lib/memory/KnowledgeGraph.js +216 -0
- package/dist/lib/memory/KnowledgeGraph.js.map +1 -0
- package/dist/lib/memory/KnowledgeGraph.test.d.ts +2 -0
- package/dist/lib/memory/KnowledgeGraph.test.d.ts.map +1 -0
- package/dist/lib/memory/KnowledgeGraph.test.js +189 -0
- package/dist/lib/memory/KnowledgeGraph.test.js.map +1 -0
- package/dist/lib/memory/MemorySearch.d.ts +25 -0
- package/dist/lib/memory/MemorySearch.d.ts.map +1 -0
- package/dist/lib/memory/MemorySearch.js +85 -0
- package/dist/lib/memory/MemorySearch.js.map +1 -0
- package/dist/lib/memory/MemorySearch.test.d.ts +2 -0
- package/dist/lib/memory/MemorySearch.test.d.ts.map +1 -0
- package/dist/lib/memory/MemorySearch.test.js +149 -0
- package/dist/lib/memory/MemorySearch.test.js.map +1 -0
- package/dist/lib/memory/MemoryStorage.d.ts +77 -0
- package/dist/lib/memory/MemoryStorage.d.ts.map +1 -0
- package/dist/lib/memory/MemoryStorage.js +278 -0
- package/dist/lib/memory/MemoryStorage.js.map +1 -0
- package/dist/lib/memory/MemoryStorage.test.d.ts +2 -0
- package/dist/lib/memory/MemoryStorage.test.d.ts.map +1 -0
- package/dist/lib/memory/MemoryStorage.test.js +198 -0
- package/dist/lib/memory/MemoryStorage.test.js.map +1 -0
- package/dist/lib/memory/index.d.ts +4 -0
- package/dist/lib/memory/index.d.ts.map +1 -0
- package/dist/lib/memory/index.js +8 -0
- package/dist/lib/memory/index.js.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator/orchestrator.js +4 -6
- package/dist/orchestrator/orchestrator.js.map +1 -1
- package/dist/tools/convention/analyzeComplexity.d.ts +3 -1
- package/dist/tools/convention/analyzeComplexity.d.ts.map +1 -1
- package/dist/tools/convention/analyzeComplexity.js +102 -4
- package/dist/tools/convention/analyzeComplexity.js.map +1 -1
- package/dist/tools/convention/analyzeComplexity.test.d.ts +2 -0
- package/dist/tools/convention/analyzeComplexity.test.d.ts.map +1 -0
- package/dist/tools/convention/analyzeComplexity.test.js +207 -0
- package/dist/tools/convention/analyzeComplexity.test.js.map +1 -0
- package/dist/tools/convention/applyQualityRules.js +1 -1
- package/dist/tools/convention/applyQualityRules.js.map +1 -1
- package/dist/tools/convention/checkCouplingCohesion.js +2 -2
- package/dist/tools/convention/checkCouplingCohesion.js.map +1 -1
- package/dist/tools/convention/suggestImprovements.js +1 -1
- package/dist/tools/convention/suggestImprovements.js.map +1 -1
- package/dist/tools/convention/validateCodeQuality.d.ts +3 -1
- package/dist/tools/convention/validateCodeQuality.d.ts.map +1 -1
- package/dist/tools/convention/validateCodeQuality.js +145 -2
- package/dist/tools/convention/validateCodeQuality.js.map +1 -1
- package/dist/tools/convention/validateCodeQuality.test.d.ts +2 -0
- package/dist/tools/convention/validateCodeQuality.test.d.ts.map +1 -0
- package/dist/tools/convention/validateCodeQuality.test.js +230 -0
- package/dist/tools/convention/validateCodeQuality.test.js.map +1 -0
- package/dist/tools/memory/autoSaveContext.js +1 -1
- package/dist/tools/memory/autoSaveContext.js.map +1 -1
- package/dist/tools/memory/createMemoryTimeline.js +27 -27
- package/dist/tools/memory/createMemoryTimeline.js.map +1 -1
- package/dist/tools/memory/deleteMemory.js +1 -1
- package/dist/tools/memory/deleteMemory.js.map +1 -1
- package/dist/tools/memory/getMemoryGraph.js +24 -24
- package/dist/tools/memory/getMemoryGraph.js.map +1 -1
- package/dist/tools/memory/getSessionContext.js +36 -36
- package/dist/tools/memory/getSessionContext.js.map +1 -1
- package/dist/tools/memory/linkMemories.js +21 -21
- package/dist/tools/memory/linkMemories.js.map +1 -1
- package/dist/tools/memory/prioritizeMemory.js +1 -1
- package/dist/tools/memory/prioritizeMemory.js.map +1 -1
- package/dist/tools/memory/restoreSessionContext.js +1 -1
- package/dist/tools/memory/restoreSessionContext.js.map +1 -1
- package/dist/tools/memory/searchMemories.js +1 -1
- package/dist/tools/memory/searchMemories.js.map +1 -1
- package/dist/tools/memory/searchMemoriesAdvanced.js +42 -42
- package/dist/tools/memory/searchMemoriesAdvanced.js.map +1 -1
- package/dist/tools/memory/startSession.js +2 -2
- package/dist/tools/memory/startSession.js.map +1 -1
- package/dist/tools/memory/updateMemory.js +1 -1
- package/dist/tools/memory/updateMemory.js.map +1 -1
- package/dist/tools/semantic/analyzeDependencyGraph.js +38 -38
- package/dist/tools/semantic/analyzeDependencyGraph.js.map +1 -1
- package/dist/tools/semantic/findReferences.js +1 -1
- package/dist/tools/semantic/findReferences.js.map +1 -1
- package/dist/tools/semantic/findSymbol.js +1 -1
- package/dist/tools/semantic/findSymbol.js.map +1 -1
- package/dist/tools/time/getCurrentTime.js +1 -1
- package/dist/tools/time/getCurrentTime.js.map +1 -1
- package/dist/tools/ui/previewUiAscii.js +2 -2
- package/dist/tools/ui/previewUiAscii.js.map +1 -1
- package/hooks/hooks.json +11 -2
- package/hooks/scripts/llm-orchestrate.js +1 -1
- package/hooks/scripts/utils.js +31 -6
- package/languages/csharp-unity.md +82 -83
- package/languages/dart-flutter.md +89 -88
- package/languages/go.md +76 -75
- package/languages/java-spring.md +85 -84
- package/languages/kotlin-android.md +64 -63
- package/languages/python-django.md +83 -82
- package/languages/python-fastapi.md +82 -81
- package/languages/rust.md +75 -74
- package/languages/swift-ios.md +73 -72
- package/languages/typescript-electron.md +70 -71
- package/languages/typescript-nextjs.md +93 -92
- package/languages/typescript-node.md +64 -63
- package/languages/typescript-nuxt.md +113 -112
- package/languages/typescript-react-native.md +82 -81
- package/languages/typescript-react.md +76 -75
- package/languages/typescript-tauri.md +74 -75
- package/languages/typescript-vue.md +73 -72
- package/package.json +1 -1
- package/skills/git-worktree.md +25 -25
- package/skills/multi-llm-orchestration.md +4 -6
- package/skills/priority-todos.md +39 -39
- package/skills/vibe-capabilities.md +2 -2
- package/vibe/config.json +2 -2
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TypeScript + React Quality Rules
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Core Principles (inherited from core)
|
|
4
4
|
|
|
5
5
|
```markdown
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
# Core Principles (inherited from core)
|
|
7
|
+
Single Responsibility (SRP)
|
|
8
|
+
No Duplication (DRY)
|
|
9
|
+
Reusability
|
|
10
|
+
Low Complexity
|
|
11
|
+
Function <= 30 lines, JSX <= 50 lines
|
|
12
|
+
Nesting <= 3 levels
|
|
13
|
+
Cyclomatic complexity <= 10
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
## TypeScript/React
|
|
16
|
+
## TypeScript/React Specific Rules
|
|
16
17
|
|
|
17
|
-
### 1.
|
|
18
|
+
### 1. 100% Type Safety
|
|
18
19
|
|
|
19
20
|
```typescript
|
|
20
|
-
//
|
|
21
|
+
// Bad: Using any
|
|
21
22
|
function processData(data: any) {
|
|
22
23
|
return data.value;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
//
|
|
26
|
+
// Good: Clear type definition
|
|
26
27
|
interface User {
|
|
27
28
|
id: string;
|
|
28
29
|
name: string;
|
|
@@ -34,7 +35,7 @@ function processUser(user: User): string {
|
|
|
34
35
|
return user.name;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
//
|
|
38
|
+
// Good: Generic usage
|
|
38
39
|
interface ApiResponse<T> {
|
|
39
40
|
success: boolean;
|
|
40
41
|
data: T;
|
|
@@ -45,10 +46,10 @@ type UserResponse = ApiResponse<User>;
|
|
|
45
46
|
type ProductResponse = ApiResponse<Product>;
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
### 2.
|
|
49
|
+
### 2. Functional Components + Hooks
|
|
49
50
|
|
|
50
51
|
```typescript
|
|
51
|
-
//
|
|
52
|
+
// Good: Functional component (recommended)
|
|
52
53
|
interface UserCardProps {
|
|
53
54
|
user: User;
|
|
54
55
|
onEdit?: (user: User) => void;
|
|
@@ -71,16 +72,16 @@ export function UserCard({ user, onEdit }: UserCardProps) {
|
|
|
71
72
|
);
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
//
|
|
75
|
+
// Bad: Class component (legacy)
|
|
75
76
|
class UserCard extends React.Component<UserCardProps> {
|
|
76
|
-
//
|
|
77
|
+
// Complex and verbose
|
|
77
78
|
}
|
|
78
79
|
```
|
|
79
80
|
|
|
80
|
-
### 3.
|
|
81
|
+
### 3. Separate Logic with Custom Hooks
|
|
81
82
|
|
|
82
83
|
```typescript
|
|
83
|
-
//
|
|
84
|
+
// Good: Custom Hook (reusable logic)
|
|
84
85
|
interface UseUserOptions {
|
|
85
86
|
userId: string;
|
|
86
87
|
}
|
|
@@ -119,7 +120,7 @@ function useUser({ userId }: UseUserOptions): UseUserReturn {
|
|
|
119
120
|
return { user, isLoading, error, refetch: fetchUser };
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
//
|
|
123
|
+
// Usage
|
|
123
124
|
function UserProfile({ userId }: { userId: string }) {
|
|
124
125
|
const { user, isLoading, error } = useUser({ userId });
|
|
125
126
|
|
|
@@ -131,10 +132,10 @@ function UserProfile({ userId }: { userId: string }) {
|
|
|
131
132
|
}
|
|
132
133
|
```
|
|
133
134
|
|
|
134
|
-
### 4. Props
|
|
135
|
+
### 4. Props Type Definition
|
|
135
136
|
|
|
136
137
|
```typescript
|
|
137
|
-
//
|
|
138
|
+
// Good: Clear Props types
|
|
138
139
|
interface ButtonProps {
|
|
139
140
|
variant?: 'primary' | 'secondary' | 'danger';
|
|
140
141
|
size?: 'sm' | 'md' | 'lg';
|
|
@@ -163,7 +164,7 @@ export function Button({
|
|
|
163
164
|
);
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
//
|
|
167
|
+
// Good: Using PropsWithChildren
|
|
167
168
|
import { PropsWithChildren } from 'react';
|
|
168
169
|
|
|
169
170
|
interface CardProps {
|
|
@@ -186,17 +187,17 @@ export function Card({
|
|
|
186
187
|
}
|
|
187
188
|
```
|
|
188
189
|
|
|
189
|
-
### 5. React Query (
|
|
190
|
+
### 5. React Query (Server State Management)
|
|
190
191
|
|
|
191
192
|
```typescript
|
|
192
|
-
//
|
|
193
|
+
// Good: Server state management with React Query
|
|
193
194
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
194
195
|
|
|
195
196
|
function useUser(userId: string) {
|
|
196
197
|
return useQuery({
|
|
197
198
|
queryKey: ['user', userId],
|
|
198
199
|
queryFn: () => fetchUser(userId),
|
|
199
|
-
staleTime: 5 * 60 * 1000, // 5
|
|
200
|
+
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
200
201
|
});
|
|
201
202
|
}
|
|
202
203
|
|
|
@@ -206,13 +207,13 @@ function useUpdateUser() {
|
|
|
206
207
|
return useMutation({
|
|
207
208
|
mutationFn: (data: UpdateUserData) => updateUser(data),
|
|
208
209
|
onSuccess: (updatedUser) => {
|
|
209
|
-
//
|
|
210
|
+
// Update cache
|
|
210
211
|
queryClient.setQueryData(['user', updatedUser.id], updatedUser);
|
|
211
212
|
},
|
|
212
213
|
});
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
//
|
|
216
|
+
// Usage
|
|
216
217
|
function UserProfile({ userId }: { userId: string }) {
|
|
217
218
|
const { data: user, isLoading, error } = useUser(userId);
|
|
218
219
|
const updateMutation = useUpdateUser();
|
|
@@ -234,10 +235,10 @@ function UserProfile({ userId }: { userId: string }) {
|
|
|
234
235
|
}
|
|
235
236
|
```
|
|
236
237
|
|
|
237
|
-
### 6.
|
|
238
|
+
### 6. Define Contract with Zod
|
|
238
239
|
|
|
239
240
|
```typescript
|
|
240
|
-
//
|
|
241
|
+
// Good: Zod schema (runtime + type validation)
|
|
241
242
|
import { z } from 'zod';
|
|
242
243
|
|
|
243
244
|
const createUserSchema = z.object({
|
|
@@ -249,7 +250,7 @@ const createUserSchema = z.object({
|
|
|
249
250
|
|
|
250
251
|
type CreateUserRequest = z.infer<typeof createUserSchema>;
|
|
251
252
|
|
|
252
|
-
//
|
|
253
|
+
// Usage (React Hook Form)
|
|
253
254
|
import { useForm } from 'react-hook-form';
|
|
254
255
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
255
256
|
|
|
@@ -288,28 +289,28 @@ function SignUpForm() {
|
|
|
288
289
|
}
|
|
289
290
|
```
|
|
290
291
|
|
|
291
|
-
### 7.
|
|
292
|
+
### 7. Component Separation (Extract Component)
|
|
292
293
|
|
|
293
294
|
```typescript
|
|
294
|
-
//
|
|
295
|
+
// Bad: Long JSX (80 lines)
|
|
295
296
|
function UserDashboard() {
|
|
296
297
|
return (
|
|
297
298
|
<div>
|
|
298
299
|
<header>
|
|
299
300
|
<h1>Dashboard</h1>
|
|
300
|
-
{/* 20
|
|
301
|
+
{/* 20 lines */}
|
|
301
302
|
</header>
|
|
302
303
|
<main>
|
|
303
|
-
{/* 40
|
|
304
|
+
{/* 40 lines */}
|
|
304
305
|
</main>
|
|
305
306
|
<footer>
|
|
306
|
-
{/* 20
|
|
307
|
+
{/* 20 lines */}
|
|
307
308
|
</footer>
|
|
308
309
|
</div>
|
|
309
310
|
);
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
//
|
|
313
|
+
// Good: Separate into sub-components
|
|
313
314
|
function UserDashboard() {
|
|
314
315
|
return (
|
|
315
316
|
<div>
|
|
@@ -333,14 +334,14 @@ function DashboardFooter() {
|
|
|
333
334
|
}
|
|
334
335
|
```
|
|
335
336
|
|
|
336
|
-
### 8. useCallback + useMemo
|
|
337
|
+
### 8. useCallback + useMemo Optimization
|
|
337
338
|
|
|
338
339
|
```typescript
|
|
339
|
-
//
|
|
340
|
+
// Good: useCallback (function memoization)
|
|
340
341
|
function Parent() {
|
|
341
342
|
const [count, setCount] = useState(0);
|
|
342
343
|
|
|
343
|
-
//
|
|
344
|
+
// Prevent creating new function every render
|
|
344
345
|
const handleClick = useCallback(() => {
|
|
345
346
|
setCount(prev => prev + 1);
|
|
346
347
|
}, []);
|
|
@@ -352,7 +353,7 @@ const Child = React.memo<{ onClick: () => void }>(({ onClick }) => {
|
|
|
352
353
|
return <button onClick={onClick}>Click</button>;
|
|
353
354
|
});
|
|
354
355
|
|
|
355
|
-
//
|
|
356
|
+
// Good: useMemo (value memoization)
|
|
356
357
|
function ExpensiveComponent({ data }: { data: number[] }) {
|
|
357
358
|
const processedData = useMemo(() => {
|
|
358
359
|
return data
|
|
@@ -368,7 +369,7 @@ function ExpensiveComponent({ data }: { data: number[] }) {
|
|
|
368
369
|
### 9. Error Boundary
|
|
369
370
|
|
|
370
371
|
```typescript
|
|
371
|
-
//
|
|
372
|
+
// Good: Error Boundary (class component required)
|
|
372
373
|
interface ErrorBoundaryProps {
|
|
373
374
|
children: React.ReactNode;
|
|
374
375
|
fallback?: React.ReactNode;
|
|
@@ -405,7 +406,7 @@ class ErrorBoundary extends React.Component<
|
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
408
|
|
|
408
|
-
//
|
|
409
|
+
// Usage
|
|
409
410
|
function App() {
|
|
410
411
|
return (
|
|
411
412
|
<ErrorBoundary fallback={<ErrorPage />}>
|
|
@@ -415,10 +416,10 @@ function App() {
|
|
|
415
416
|
}
|
|
416
417
|
```
|
|
417
418
|
|
|
418
|
-
### 10.
|
|
419
|
+
### 10. Type Guards
|
|
419
420
|
|
|
420
421
|
```typescript
|
|
421
|
-
//
|
|
422
|
+
// Good: Type guards
|
|
422
423
|
interface Dog {
|
|
423
424
|
type: 'dog';
|
|
424
425
|
bark: () => void;
|
|
@@ -437,13 +438,13 @@ function isDog(animal: Animal): animal is Dog {
|
|
|
437
438
|
|
|
438
439
|
function makeSound(animal: Animal) {
|
|
439
440
|
if (isDog(animal)) {
|
|
440
|
-
animal.bark(); //
|
|
441
|
+
animal.bark(); // Type safe
|
|
441
442
|
} else {
|
|
442
|
-
animal.meow(); //
|
|
443
|
+
animal.meow(); // Type safe
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
446
|
|
|
446
|
-
//
|
|
447
|
+
// Good: Discriminated Union
|
|
447
448
|
function AnimalCard({ animal }: { animal: Animal }) {
|
|
448
449
|
switch (animal.type) {
|
|
449
450
|
case 'dog':
|
|
@@ -454,46 +455,46 @@ function AnimalCard({ animal }: { animal: Animal }) {
|
|
|
454
455
|
}
|
|
455
456
|
```
|
|
456
457
|
|
|
457
|
-
##
|
|
458
|
+
## Anti-patterns
|
|
458
459
|
|
|
459
460
|
```typescript
|
|
460
|
-
//
|
|
461
|
+
// Bad: Props drilling (3+ levels)
|
|
461
462
|
<GrandParent user={user}>
|
|
462
463
|
<Parent user={user}>
|
|
463
464
|
<Child user={user} />
|
|
464
465
|
</Parent>
|
|
465
466
|
</GrandParent>
|
|
466
467
|
|
|
467
|
-
//
|
|
468
|
+
// Good: Use Context
|
|
468
469
|
const UserContext = createContext<User | undefined>(undefined);
|
|
469
470
|
|
|
470
471
|
<UserContext.Provider value={user}>
|
|
471
472
|
<GrandParent />
|
|
472
473
|
</UserContext.Provider>
|
|
473
474
|
|
|
474
|
-
//
|
|
475
|
+
// Bad: Missing useEffect dependency
|
|
475
476
|
useEffect(() => {
|
|
476
477
|
fetchUser(userId);
|
|
477
|
-
}, []); // userId
|
|
478
|
+
}, []); // userId dependency missing!
|
|
478
479
|
|
|
479
|
-
//
|
|
480
|
+
// Good: Specify all dependencies
|
|
480
481
|
useEffect(() => {
|
|
481
482
|
fetchUser(userId);
|
|
482
483
|
}, [userId]);
|
|
483
484
|
|
|
484
|
-
//
|
|
485
|
+
// Bad: Inline objects/functions (cause re-renders)
|
|
485
486
|
<Child config={{ theme: 'dark' }} onClick={() => {}} />
|
|
486
487
|
|
|
487
|
-
//
|
|
488
|
+
// Good: useMemo/useCallback
|
|
488
489
|
const config = useMemo(() => ({ theme: 'dark' }), []);
|
|
489
490
|
const handleClick = useCallback(() => {}, []);
|
|
490
491
|
<Child config={config} onClick={handleClick} />
|
|
491
492
|
```
|
|
492
493
|
|
|
493
|
-
##
|
|
494
|
+
## Code Quality Tools
|
|
494
495
|
|
|
495
496
|
```bash
|
|
496
|
-
# TypeScript
|
|
497
|
+
# TypeScript compile
|
|
497
498
|
tsc --noEmit
|
|
498
499
|
|
|
499
500
|
# ESLint
|
|
@@ -502,24 +503,24 @@ eslint src/ --ext .ts,.tsx
|
|
|
502
503
|
# Prettier
|
|
503
504
|
prettier --write src/
|
|
504
505
|
|
|
505
|
-
#
|
|
506
|
+
# Testing
|
|
506
507
|
vitest
|
|
507
508
|
# or
|
|
508
509
|
jest
|
|
509
510
|
```
|
|
510
511
|
|
|
511
|
-
##
|
|
512
|
-
|
|
513
|
-
TypeScript/React
|
|
514
|
-
|
|
515
|
-
- [ ]
|
|
516
|
-
- [ ]
|
|
517
|
-
- [ ] Custom Hook
|
|
518
|
-
- [ ] Props
|
|
519
|
-
- [ ]
|
|
520
|
-
- [ ]
|
|
521
|
-
- [ ] JSX
|
|
522
|
-
- [ ] useCallback/useMemo
|
|
523
|
-
- [ ] Error Boundary
|
|
524
|
-
- [ ]
|
|
525
|
-
- [ ]
|
|
512
|
+
## Checklist
|
|
513
|
+
|
|
514
|
+
When writing TypeScript/React code:
|
|
515
|
+
|
|
516
|
+
- [ ] 100% type safety (no any)
|
|
517
|
+
- [ ] Functional components + Hooks
|
|
518
|
+
- [ ] Separate logic with Custom Hook
|
|
519
|
+
- [ ] Clear Props type definition
|
|
520
|
+
- [ ] Server state with React Query
|
|
521
|
+
- [ ] Define Contract with Zod
|
|
522
|
+
- [ ] JSX <= 50 lines (component separation)
|
|
523
|
+
- [ ] useCallback/useMemo optimization
|
|
524
|
+
- [ ] Use Error Boundary
|
|
525
|
+
- [ ] Use type guards
|
|
526
|
+
- [ ] Complexity <= 10
|