AgentLint 实测验证 100/100基于 1,031 个 React + Vite 开源仓库统计

    React + Vite CLAUDE.md & AGENTS.md 模板

    严格组件 Props、可预测 Hooks 写法与秒级 Vitest/Testing Library 循环,提炼自 1,031 个 React 仓库。

    # React + Vite App — Frontend Harness
    
    Vite + React 18 + TypeScript single-page application styled with Tailwind CSS and tested with Vitest + Testing Library.
    
    ## Commands
    
    - Install: `pnpm install --frozen-lockfile`
    - Fast single test: `npx vitest run src/components/FilterBar.test.tsx`
    - Full unit suite: `pnpm test`
    - Lint & typecheck: `pnpm lint && npx tsc --noEmit`
    - Build: `pnpm build`
    
    ## Rules
    
    - Don't mirror props or computable values into `useState` + `useEffect`. Instead derive values directly during render or via `useMemo`. Because effect-synced state triggers double renders and stale UI bugs.
    - Don't silence `react-hooks/exhaustive-deps` warnings with ESLint disable comments. Instead extract stable callbacks or restructure state. Because missing dependencies hide stale-closure defects.
    - Don't introduce new primitive UI components before checking `src/components/ui/`. Instead reuse existing primitives so focus states and tokens stay consistent.
    - When changing client routes or state stores, read `docs/frontend-architecture.md` first.
    
    ## Continuity & Safety
    
    - Keep `.env*` and `CLAUDE.local.md` out of git — never embed private keys in `VITE_*` browser variables.
    - Record passing test commands and visual check notes in `HANDOFF.md`.

    React + Vite 开源生态中最常采用的工程规则

    基于 4,533 仓库研究中 1,031 个公开 React + Vite 仓库的实测统计:

    react框架

    React component patterns (940 TypeScript + 91 JavaScript repos in corpus)

    57.5%1031 个仓库
    tailwindcss工具链

    Tailwind CSS utility styling

    38.8%595 个仓库
    unit-tests测试

    Component & hook unit tests for every change

    36.3%651 个仓库
    eslint工具链

    ESLint + react-hooks exhaustive-deps

    36.9%565 个仓库
    vitest测试

    Vitest + React Testing Library

    32.6%499 个仓库
    必写验证命令(对应规则 W1 与 W7)
    安装依赖
    pnpm install --frozen-lockfile
    快速单测(秒级迭代)
    npx vitest run src/components/CheckoutForm.test.tsx
    全量测试
    pnpm test
    Lint 与静态检查
    pnpm lint && npx tsc --noEmit
    生产构建
    pnpm build
    React + Vite 项目中 AI 代理常见踩坑
    • 01用 useState + useEffect 同步本可直接计算派生的值,造成闪烁和闭包陈旧 bug。
    • 02随意透传无类型 ...props 破坏组件契约与 DOM 属性校验。
    • 03Effect 忘记清理订阅或定时器导致单测句柄泄漏。

    更多实证验证模板