Typescript React Reviewer

dotneet/claude-code-marketplace/review-tool/skills/typescript-react-reviewer

作者 dotneet07fa7eac95c2無授權條款3 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫8 個月前更新

Expert code reviewer for TypeScript + React 19 applications. Use when reviewing React code, identifying anti-patterns, evaluating state management, or assessing code maintainability. Triggers: code review requests, PR reviews, React architecture evaluation, identifying code smells, TypeScript type safety checks, useEffect abuse detection, state management review.

AI 產生的概覽

審查 TypeScript 與 React 19 程式碼,指出反模式、Hook 誤用、狀態管理問題與型別安全問題。

功能
提供針對 TypeScript 與 React 19 應用程式的結構化程式碼審查指南,依優先層級編排,從阻擋合併的嚴重問題到架構與風格建議。內容列出 useEffect 濫用、React 19 Hook 錯誤、狀態直接變更、TypeScript 危險訊號以及狀態管理反模式的偵測模式,並附上錯誤與正確寫法範例。它也定義審查流程,並指向隨附的參考文件,涵蓋 React 19 模式、反模式目錄與完整審查清單。
適用情境
適用於審查 React 或 TypeScript 的拉取請求、評估元件架構,或檢查 Hook 用法與型別安全。也適合找出程式碼異味、評估可維護性,或審視 React 19 程式庫中的狀態管理做法。
執行需求
不需要任何指令碼或工具,僅為說明性內容。它引用了 references 資料夾中的三份隨附 Markdown 文件。

TypeScript + React 19 Code Review Expert

Expert code reviewer with deep knowledge of React 19's new features, TypeScript best practices, state management patterns, and common anti-patterns.

Review Priority Levels

🚫 Critical (Block Merge)

These issues cause bugs, memory leaks, or architectural problems:

IssueWhy It's Critical
useEffect for derived stateExtra render cycle, sync bugs
Missing cleanup in useEffectMemory leaks
Direct state mutation (.push(), .splice())Silent update failures
Conditional hook callsBreaks Rules of Hooks
key={index} in dynamic listsState corruption on reorder
any type without justificationType safety bypass
useFormStatus in same component as <form>Always returns false (React 19 bug)
Promise created inside render with use()Infinite loop

⚠️ High Priority

IssueImpact
Incomplete dependency arraysStale closures, missing updates
Props typed as anyRuntime errors
Unjustified useMemo/useCallbackUnnecessary complexity
Missing Error BoundariesPoor error UX
Controlled input initialized with undefinedReact warning

📝 Architecture/Style

IssueRecommendation
Component > 300 linesSplit into smaller components
Prop drilling > 2-3 levelsUse composition or context
State far from usageColocate state
Custom hooks without use prefixFollow naming convention

Quick Detection Patterns

useEffect Abuse (Most Common Anti-Pattern)

typescript
// ❌ WRONG: Derived state in useEffectconst [firstName, setFirstName] = useState('');const [fullName, setFullName] = useState('');useEffect(() => {  setFullName(firstName + ' ' + lastName);}, [firstName, lastName]);
// ✅ CORRECT: Compute during renderconst fullName = firstName + ' ' + lastName;
typescript
// ❌ WRONG: Event logic in useEffectuseEffect(() => {  if (product.isInCart) showNotification('Added!');}, [product]);
// ✅ CORRECT: Logic in event handlerfunction handleAddToCart() {  addToCart(product);  showNotification('Added!');}

React 19 Hook Mistakes

typescript
// ❌ WRONG: useFormStatus in form component (always returns false)function Form() {  const { pending } = useFormStatus();  return <form action={submit}><button disabled={pending}>Send</button></form>;}
// ✅ CORRECT: useFormStatus in child componentfunction SubmitButton() {  const { pending } = useFormStatus();  return <button type="submit" disabled={pending}>Send</button>;}function Form() {  return <form action={submit}><SubmitButton /></form>;}
typescript
// ❌ WRONG: Promise created in render (infinite loop)function Component() {  const data = use(fetch('/api/data')); // New promise every render!}
// ✅ CORRECT: Promise from props or statefunction Component({ dataPromise }: { dataPromise: Promise<Data> }) {  const data = use(dataPromise);}

State Mutation Detection

typescript
// ❌ WRONG: Mutations (no re-render)items.push(newItem);setItems(items);
arr[i] = newValue;setArr(arr);
// ✅ CORRECT: Immutable updatessetItems([...items, newItem]);setArr(arr.map((x, idx) => idx === i ? newValue : x));

TypeScript Red Flags

typescript
// ❌ Red flags to catchconst data: any = response;           // Unsafe anyconst items = arr[10];                // Missing undefined checkconst App: React.FC<Props> = () => {}; // Discouraged pattern
// ✅ Preferred patternsconst data: ResponseType = response;const items = arr[10]; // with noUncheckedIndexedAccessconst App = ({ prop }: Props) => {};  // Explicit props

Review Workflow

  1. Scan for critical issues first - Check for the patterns in "Critical (Block Merge)" section
  2. Check React 19 usage - See react19-patterns.md [blocked] for new API patterns
  3. Evaluate state management - Is state colocated? Server state vs client state separation?
  4. Assess TypeScript safety - Generic components, discriminated unions, strict config
  5. Review for maintainability - Component size, hook design, folder structure

Reference Documents

For detailed patterns and examples:

  • react19-patterns.md [blocked] - React 19 new hooks (useActionState, useOptimistic, use), Server/Client Component boundaries
  • antipatterns.md [blocked] - Comprehensive anti-pattern catalog with fixes
  • checklist.md [blocked] - Full code review checklist for thorough reviews

State Management Quick Guide

Data TypeSolution
Server/async dataTanStack Query (never copy to local state)
Simple global UI stateZustand (~1KB, no Provider)
Fine-grained derived stateJotai (~2.4KB)
Component-local stateuseState/useReducer
Form stateReact 19 useActionState

TanStack Query Anti-Pattern

typescript
// ❌ NEVER copy server data to local stateconst { data } = useQuery({ queryKey: ['todos'], queryFn: fetchTodos });const [todos, setTodos] = useState([]);useEffect(() => setTodos(data), [data]);
// ✅ Query IS the source of truthconst { data: todos } = useQuery({ queryKey: ['todos'], queryFn: fetchTodos });

TypeScript Config Recommendations

json
{  "compilerOptions": {    "strict": true,    "noUncheckedIndexedAccess": true,    "noImplicitReturns": true,    "exactOptionalPropertyTypes": true  }}

noUncheckedIndexedAccess is critical - it catches arr[i] returning undefined.

Immediate Red Flags

When reviewing, flag these immediately:

PatternProblemFix
eslint-disable react-hooks/exhaustive-depsHides stale closure bugsRefactor logic
Component defined inside componentRemounts every renderMove outside
useState(undefined) for inputsUncontrolled warningUse empty string
React.FC with genericsGeneric inference breaksUse explicit props
Barrel files (index.ts) in app codeBundle bloat, circular depsDirect imports

來源與署名

來源:dotneet/claude-code-marketplace位於review-tool/skills/typescript-react-reviewer提交07fa7ea

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架