create-huenei-template 0.2.14 → 0.2.15
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/dist/config/templates.js +7 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
- package/dist/templates/frontend/react-ssr/.dockerignore +14 -0
- package/dist/templates/frontend/react-ssr/.env.example +9 -0
- package/dist/templates/frontend/react-ssr/.husky/pre-commit +1 -0
- package/dist/templates/frontend/react-ssr/Dockerfile +41 -0
- package/dist/templates/frontend/react-ssr/README.md +121 -0
- package/dist/templates/frontend/react-ssr/components.json +22 -0
- package/dist/templates/frontend/react-ssr/docker-compose.yml +21 -0
- package/dist/templates/frontend/react-ssr/eslint.config.mjs +26 -0
- package/dist/templates/frontend/react-ssr/next.config.ts +7 -0
- package/dist/templates/frontend/react-ssr/package.json +86 -0
- package/dist/templates/frontend/react-ssr/postcss.config.mjs +5 -0
- package/dist/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
- package/dist/templates/frontend/react-ssr/prisma/seed.ts +109 -0
- package/dist/templates/frontend/react-ssr/prisma.config.ts +17 -0
- package/dist/templates/frontend/react-ssr/skills-lock.json +65 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
- package/dist/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
- package/dist/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
- package/dist/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
- package/dist/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
- package/dist/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
- package/dist/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
- package/dist/templates/frontend/react-ssr/src/app/globals.css +99 -0
- package/dist/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
- package/dist/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
- package/dist/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
- package/dist/templates/frontend/react-ssr/src/app/page.tsx +331 -0
- package/dist/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
- package/dist/templates/frontend/react-ssr/src/auth.ts +64 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
- package/dist/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
- package/dist/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
- package/dist/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
- package/dist/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
- package/dist/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
- package/dist/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
- package/dist/templates/frontend/react-ssr/src/proxy.ts +31 -0
- package/dist/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
- package/dist/templates/frontend/react-ssr/src/test/setup.ts +1 -0
- package/dist/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
- package/dist/templates/frontend/react-ssr/src/types/index.ts +36 -0
- package/dist/templates/frontend/react-ssr/tsconfig.json +41 -0
- package/dist/templates/frontend/react-ssr/vitest.config.ts +41 -0
- package/package.json +1 -1
- package/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
- package/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
- package/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
- package/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
- package/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
- package/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
- package/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
- package/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
- package/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
- package/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
- package/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
- package/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
- package/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
- package/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
- package/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
- package/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
- package/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
- package/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
- package/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
- package/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
- package/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
- package/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
- package/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
- package/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
- package/templates/frontend/react-ssr/.dockerignore +14 -0
- package/templates/frontend/react-ssr/.env.example +9 -0
- package/templates/frontend/react-ssr/.husky/pre-commit +1 -0
- package/templates/frontend/react-ssr/Dockerfile +41 -0
- package/templates/frontend/react-ssr/README.md +121 -0
- package/templates/frontend/react-ssr/components.json +22 -0
- package/templates/frontend/react-ssr/docker-compose.yml +21 -0
- package/templates/frontend/react-ssr/eslint.config.mjs +26 -0
- package/templates/frontend/react-ssr/next.config.ts +7 -0
- package/templates/frontend/react-ssr/package.json +86 -0
- package/templates/frontend/react-ssr/postcss.config.mjs +5 -0
- package/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
- package/templates/frontend/react-ssr/prisma/seed.ts +109 -0
- package/templates/frontend/react-ssr/prisma.config.ts +17 -0
- package/templates/frontend/react-ssr/skills-lock.json +65 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
- package/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
- package/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
- package/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
- package/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
- package/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
- package/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
- package/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
- package/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
- package/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
- package/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
- package/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
- package/templates/frontend/react-ssr/src/app/globals.css +99 -0
- package/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
- package/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
- package/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
- package/templates/frontend/react-ssr/src/app/page.tsx +331 -0
- package/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
- package/templates/frontend/react-ssr/src/auth.ts +64 -0
- package/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
- package/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
- package/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
- package/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
- package/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
- package/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
- package/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
- package/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
- package/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
- package/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
- package/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
- package/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
- package/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
- package/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
- package/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
- package/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
- package/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
- package/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
- package/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
- package/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
- package/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
- package/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
- package/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
- package/templates/frontend/react-ssr/src/proxy.ts +31 -0
- package/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
- package/templates/frontend/react-ssr/src/test/setup.ts +1 -0
- package/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
- package/templates/frontend/react-ssr/src/types/index.ts +36 -0
- package/templates/frontend/react-ssr/tsconfig.json +41 -0
- package/templates/frontend/react-ssr/vitest.config.ts +41 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# React Hook Form Best Practices Skill
|
|
2
|
+
|
|
3
|
+
Performance optimization guidelines for React Hook Form applications.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This skill provides 41 performance rules across 8 categories, designed to help AI agents and developers write performant React Hook Form code.
|
|
8
|
+
|
|
9
|
+
### Directory Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
react-hook-form/
|
|
13
|
+
├── SKILL.md # Entry point with quick reference
|
|
14
|
+
├── AGENTS.md # Compiled comprehensive guide
|
|
15
|
+
├── metadata.json # Version, org, references
|
|
16
|
+
├── README.md # This file
|
|
17
|
+
└── rules/
|
|
18
|
+
├── _sections.md # Category definitions
|
|
19
|
+
├── _template.md # Rule template
|
|
20
|
+
├── config-*.md # Form configuration rules (6)
|
|
21
|
+
├── sub-*.md # Field subscription rules (7)
|
|
22
|
+
├── ctrl-*.md # Controlled component rules (5)
|
|
23
|
+
├── valid-*.md # Validation pattern rules (6)
|
|
24
|
+
├── array-*.md # Field array rules (5)
|
|
25
|
+
├── state-*.md # State management rules (5)
|
|
26
|
+
├── integ-*.md # Integration pattern rules (4)
|
|
27
|
+
└── adv-*.md # Advanced pattern rules (3)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Getting Started
|
|
31
|
+
|
|
32
|
+
### Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Build AGENTS.md
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pnpm build
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Validate Skill
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm validate
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Creating a New Rule
|
|
51
|
+
|
|
52
|
+
1. Choose the appropriate category prefix:
|
|
53
|
+
|
|
54
|
+
| Category | Prefix | Impact |
|
|
55
|
+
|----------|--------|--------|
|
|
56
|
+
| Form Configuration | `config-` | CRITICAL |
|
|
57
|
+
| Field Subscription | `sub-` | CRITICAL |
|
|
58
|
+
| Controlled Components | `ctrl-` | HIGH |
|
|
59
|
+
| Validation Patterns | `valid-` | HIGH |
|
|
60
|
+
| Field Arrays | `array-` | MEDIUM-HIGH |
|
|
61
|
+
| State Management | `state-` | MEDIUM |
|
|
62
|
+
| Integration Patterns | `integ-` | MEDIUM |
|
|
63
|
+
| Advanced Patterns | `adv-` | LOW |
|
|
64
|
+
|
|
65
|
+
2. Create a new file: `rules/{prefix}-{description}.md`
|
|
66
|
+
|
|
67
|
+
3. Use the rule template from `rules/_template.md`
|
|
68
|
+
|
|
69
|
+
## Rule File Structure
|
|
70
|
+
|
|
71
|
+
```markdown
|
|
72
|
+
---
|
|
73
|
+
title: Rule Title Here
|
|
74
|
+
impact: CRITICAL|HIGH|MEDIUM-HIGH|MEDIUM|LOW-MEDIUM|LOW
|
|
75
|
+
impactDescription: Quantified impact (e.g., "2-10× improvement")
|
|
76
|
+
tags: prefix, keyword1, keyword2
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Rule Title Here
|
|
80
|
+
|
|
81
|
+
Brief explanation of WHY this matters (1-3 sentences).
|
|
82
|
+
|
|
83
|
+
**Incorrect (description of problem):**
|
|
84
|
+
|
|
85
|
+
\`\`\`typescript
|
|
86
|
+
// Bad code with comment on key line
|
|
87
|
+
\`\`\`
|
|
88
|
+
|
|
89
|
+
**Correct (description of solution):**
|
|
90
|
+
|
|
91
|
+
\`\`\`typescript
|
|
92
|
+
// Good code with minimal diff from incorrect
|
|
93
|
+
\`\`\`
|
|
94
|
+
|
|
95
|
+
Reference: [Documentation Link](https://example.com)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## File Naming Convention
|
|
99
|
+
|
|
100
|
+
Rules follow the pattern: `{prefix}-{slug}.md`
|
|
101
|
+
|
|
102
|
+
- **prefix**: Category identifier (3-8 chars) from `_sections.md`
|
|
103
|
+
- **slug**: Kebab-case description of the rule
|
|
104
|
+
|
|
105
|
+
Examples:
|
|
106
|
+
- `config-validation-mode.md`
|
|
107
|
+
- `sub-usewatch-over-watch.md`
|
|
108
|
+
- `ctrl-usecontroller-isolation.md`
|
|
109
|
+
|
|
110
|
+
## Impact Levels
|
|
111
|
+
|
|
112
|
+
| Level | Description |
|
|
113
|
+
|-------|-------------|
|
|
114
|
+
| CRITICAL | Cascade effect on entire form performance |
|
|
115
|
+
| HIGH | Significant impact on specific operations |
|
|
116
|
+
| MEDIUM-HIGH | Notable improvement for common patterns |
|
|
117
|
+
| MEDIUM | Measurable improvement in specific scenarios |
|
|
118
|
+
| LOW-MEDIUM | Minor optimization for edge cases |
|
|
119
|
+
| LOW | Best practice with minimal performance impact |
|
|
120
|
+
|
|
121
|
+
## Scripts
|
|
122
|
+
|
|
123
|
+
| Command | Description |
|
|
124
|
+
|---------|-------------|
|
|
125
|
+
| `pnpm build` | Compile rules into AGENTS.md |
|
|
126
|
+
| `pnpm validate` | Check skill against quality guidelines |
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
1. Read existing rules in the same category for style consistency
|
|
131
|
+
2. Ensure incorrect/correct examples have minimal diff
|
|
132
|
+
3. Quantify impact where possible
|
|
133
|
+
4. Include authoritative reference links
|
|
134
|
+
5. Run validation before submitting
|
|
135
|
+
|
|
136
|
+
## Acknowledgments
|
|
137
|
+
|
|
138
|
+
Based on official React Hook Form documentation and community best practices.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-hook-form
|
|
3
|
+
description: React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, and useFieldArray. This skill should be used when building client-side controlled forms with React Hook Form library. This skill does NOT cover React 19 Server Actions, useActionState, or server-side form handling (use react-19 skill for those).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# React Hook Form Best Practices
|
|
7
|
+
|
|
8
|
+
Comprehensive performance optimization guide for React Hook Form applications. Contains 41 rules across 8 categories, prioritized by impact to guide form development, automated refactoring, and code generation.
|
|
9
|
+
|
|
10
|
+
## When to Apply
|
|
11
|
+
|
|
12
|
+
Reference these guidelines when:
|
|
13
|
+
- Writing new forms with React Hook Form
|
|
14
|
+
- Configuring useForm options (mode, defaultValues, validation)
|
|
15
|
+
- Subscribing to form values with watch/useWatch
|
|
16
|
+
- Integrating controlled UI components (MUI, shadcn, Ant Design)
|
|
17
|
+
- Managing dynamic field arrays with useFieldArray
|
|
18
|
+
- Reviewing forms for performance issues
|
|
19
|
+
|
|
20
|
+
## Rule Categories by Priority
|
|
21
|
+
|
|
22
|
+
| Priority | Category | Impact | Prefix |
|
|
23
|
+
|----------|----------|--------|--------|
|
|
24
|
+
| 1 | Form Configuration | CRITICAL | `formcfg-` |
|
|
25
|
+
| 2 | Field Subscription | CRITICAL | `sub-` |
|
|
26
|
+
| 3 | Controlled Components | HIGH | `ctrl-` |
|
|
27
|
+
| 4 | Validation Patterns | HIGH | `valid-` |
|
|
28
|
+
| 5 | Field Arrays | MEDIUM-HIGH | `array-` |
|
|
29
|
+
| 6 | State Management | MEDIUM | `formstate-` |
|
|
30
|
+
| 7 | Integration Patterns | MEDIUM | `integ-` |
|
|
31
|
+
| 8 | Advanced Patterns | LOW | `adv-` |
|
|
32
|
+
|
|
33
|
+
## Quick Reference
|
|
34
|
+
|
|
35
|
+
### 1. Form Configuration (CRITICAL)
|
|
36
|
+
|
|
37
|
+
- `formcfg-validation-mode` - Use onSubmit mode for optimal performance
|
|
38
|
+
- `formcfg-revalidate-mode` - Set reValidateMode to onBlur for post-submit performance
|
|
39
|
+
- `formcfg-default-values` - Always provide defaultValues for form initialization
|
|
40
|
+
- `formcfg-async-default-values` - Use async defaultValues for server data
|
|
41
|
+
- `formcfg-should-unregister` - Enable shouldUnregister for dynamic form memory efficiency
|
|
42
|
+
- `formcfg-useeffect-dependency` - Avoid useForm return object in useEffect dependencies
|
|
43
|
+
|
|
44
|
+
### 2. Field Subscription (CRITICAL)
|
|
45
|
+
|
|
46
|
+
- `sub-usewatch-over-watch` - Use useWatch instead of watch for isolated re-renders
|
|
47
|
+
- `sub-watch-specific-fields` - Watch specific fields instead of entire form
|
|
48
|
+
- `sub-usewatch-with-getvalues` - Combine useWatch with getValues for timing safety
|
|
49
|
+
- `sub-deep-subscription` - Subscribe deep in component tree where data is needed
|
|
50
|
+
- `sub-avoid-watch-in-render` - Avoid calling watch() in render for one-time reads
|
|
51
|
+
- `sub-usewatch-default-value` - Provide defaultValue to useWatch for initial render
|
|
52
|
+
- `sub-useformcontext-sparingly` - Use useFormContext sparingly for deep nesting
|
|
53
|
+
|
|
54
|
+
### 3. Controlled Components (HIGH)
|
|
55
|
+
|
|
56
|
+
- `ctrl-usecontroller-isolation` - Use useController for re-render isolation
|
|
57
|
+
- `ctrl-avoid-double-registration` - Avoid double registration with useController
|
|
58
|
+
- `ctrl-controller-field-props` - Wire Controller field props correctly for UI libraries
|
|
59
|
+
- `ctrl-single-usecontroller-per-component` - Use single useController per component
|
|
60
|
+
- `ctrl-local-state-combination` - Combine local state with useController for UI-only state
|
|
61
|
+
|
|
62
|
+
### 4. Validation Patterns (HIGH)
|
|
63
|
+
|
|
64
|
+
- `valid-resolver-caching` - Define schema outside component for resolver caching
|
|
65
|
+
- `valid-dynamic-schema-factory` - Use schema factory for dynamic validation
|
|
66
|
+
- `valid-error-message-strategy` - Access errors via optional chaining or lodash get
|
|
67
|
+
- `valid-inline-vs-resolver` - Prefer resolver over inline validation for complex rules
|
|
68
|
+
- `valid-delay-error` - Use delayError to debounce rapid error display
|
|
69
|
+
- `valid-native-validation` - Consider native validation for simple forms
|
|
70
|
+
|
|
71
|
+
### 5. Field Arrays (MEDIUM-HIGH)
|
|
72
|
+
|
|
73
|
+
- `array-use-field-id-as-key` - Use field.id as key in useFieldArray maps
|
|
74
|
+
- `array-complete-default-objects` - Provide complete default objects for field array operations
|
|
75
|
+
- `array-separate-crud-operations` - Separate sequential field array operations
|
|
76
|
+
- `array-unique-fieldarray-per-name` - Use single useFieldArray instance per field name
|
|
77
|
+
- `array-virtualization-formprovider` - Use FormProvider for virtualized field arrays
|
|
78
|
+
|
|
79
|
+
### 6. State Management (MEDIUM)
|
|
80
|
+
|
|
81
|
+
- `formstate-destructure-formstate` - Destructure formState properties before render
|
|
82
|
+
- `formstate-useformstate-isolation` - Use useFormState for isolated state subscriptions
|
|
83
|
+
- `formstate-getfieldstate-for-single-field` - Use getFieldState for single field state access
|
|
84
|
+
- `formstate-subscribe-to-specific-fields` - Subscribe to specific field names in useFormState
|
|
85
|
+
- `formstate-avoid-isvalid-with-onsubmit` - Avoid isValid with onSubmit mode for button state
|
|
86
|
+
|
|
87
|
+
### 7. Integration Patterns (MEDIUM)
|
|
88
|
+
|
|
89
|
+
- `integ-shadcn-form-import` - Verify shadcn Form component import source
|
|
90
|
+
- `integ-shadcn-select-wiring` - Wire shadcn Select with onValueChange instead of spread
|
|
91
|
+
- `integ-mui-controller-pattern` - Use Controller for Material-UI components
|
|
92
|
+
- `integ-value-transform` - Transform values at Controller level for type coercion
|
|
93
|
+
|
|
94
|
+
### 8. Advanced Patterns (LOW)
|
|
95
|
+
|
|
96
|
+
- `adv-formprovider-memo` - Wrap FormProvider children with React.memo
|
|
97
|
+
- `adv-devtools-performance` - Disable DevTools in production and during performance testing
|
|
98
|
+
- `adv-testing-wrapper` - Create test wrapper with QueryClient and AuthProvider
|
|
99
|
+
|
|
100
|
+
## How to Use
|
|
101
|
+
|
|
102
|
+
Read individual reference files for detailed explanations and code examples:
|
|
103
|
+
|
|
104
|
+
- [Section definitions](references/_sections.md) - Category structure and impact levels
|
|
105
|
+
- [Rule template](assets/templates/_template.md) - Template for adding new rules
|
|
106
|
+
- Reference files: `references/{prefix}-{slug}.md`
|
|
107
|
+
|
|
108
|
+
## Related Skills
|
|
109
|
+
|
|
110
|
+
- For schema validation with Zod resolver, see `zod` skill
|
|
111
|
+
- For React 19 server actions, see `react-19` skill
|
|
112
|
+
- For UI/UX form design, see `frontend-design` skill
|
|
113
|
+
|
|
114
|
+
## Full Compiled Document
|
|
115
|
+
|
|
116
|
+
For the complete guide with all rules expanded: `AGENTS.md`
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Rule Title Here
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: Optional description of impact (e.g., "20-50% improvement")
|
|
5
|
+
tags: prefix, tag1, tag2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Rule Title Here
|
|
9
|
+
|
|
10
|
+
Brief explanation of the rule and why it matters. This should be clear and concise, explaining the performance implications.
|
|
11
|
+
|
|
12
|
+
**Incorrect (description of what's wrong):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
// Bad code example here
|
|
16
|
+
const bad = example()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Correct (description of what's right):**
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
// Good code example here
|
|
23
|
+
const good = example()
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Reference: [Link to documentation or resource](https://example.com)
|
package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Sections
|
|
2
|
+
|
|
3
|
+
This file defines all sections, their ordering, impact levels, and descriptions.
|
|
4
|
+
The section ID (in parentheses) is the filename prefix used to group rules.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Form Configuration (formcfg)
|
|
9
|
+
|
|
10
|
+
**Impact:** CRITICAL
|
|
11
|
+
**Description:** Initial useForm setup determines validation timing, re-render boundaries, and default value caching. Incorrect mode selection causes re-renders on every keystroke.
|
|
12
|
+
|
|
13
|
+
## 2. Field Subscription (sub)
|
|
14
|
+
|
|
15
|
+
**Impact:** CRITICAL
|
|
16
|
+
**Description:** Isolating field subscriptions prevents cascade re-renders across the form tree. Using watch() at root vs useWatch() in children is the #1 performance differentiator.
|
|
17
|
+
|
|
18
|
+
## 3. Controlled Components (ctrl)
|
|
19
|
+
|
|
20
|
+
**Impact:** HIGH
|
|
21
|
+
**Description:** Proper Controller/useController usage isolates re-renders to individual fields. Incorrect patterns cause N×M re-renders with controlled UI libraries.
|
|
22
|
+
|
|
23
|
+
## 4. Validation Patterns (valid)
|
|
24
|
+
|
|
25
|
+
**Impact:** HIGH
|
|
26
|
+
**Description:** Schema resolver caching, validation mode selection, and error handling patterns affect validation cost per keystroke.
|
|
27
|
+
|
|
28
|
+
## 5. Field Arrays (array)
|
|
29
|
+
|
|
30
|
+
**Impact:** MEDIUM-HIGH
|
|
31
|
+
**Description:** Dynamic field management requires proper key handling and state isolation to prevent stale data and excess re-renders during CRUD operations.
|
|
32
|
+
|
|
33
|
+
## 6. State Management (formstate)
|
|
34
|
+
|
|
35
|
+
**Impact:** MEDIUM
|
|
36
|
+
**Description:** FormState access via Proxy subscription optimization requires explicit destructuring. Accessing entire formState object disables optimization.
|
|
37
|
+
|
|
38
|
+
## 7. Integration Patterns (integ)
|
|
39
|
+
|
|
40
|
+
**Impact:** MEDIUM
|
|
41
|
+
**Description:** Third-party UI library integration (MUI, shadcn, Ant Design) requires specific wiring patterns to maintain uncontrolled component benefits.
|
|
42
|
+
|
|
43
|
+
## 8. Advanced Patterns (adv)
|
|
44
|
+
|
|
45
|
+
**Impact:** LOW
|
|
46
|
+
**Description:** FormProvider optimization with React.memo, DevTools performance impact awareness, and testing patterns for hook-based forms.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Disable DevTools in Production and During Performance Testing
|
|
3
|
+
impact: LOW
|
|
4
|
+
impactDescription: eliminates DevTools overhead during profiling
|
|
5
|
+
tags: adv, devtools, performance, debugging
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Disable DevTools in Production and During Performance Testing
|
|
9
|
+
|
|
10
|
+
React Hook Form DevTools can cause performance issues, especially with FormProvider. Always disable in production and temporarily remove when profiling performance.
|
|
11
|
+
|
|
12
|
+
**Incorrect (DevTools enabled regardless of environment):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { DevTool } from '@hookform/devtools'
|
|
16
|
+
|
|
17
|
+
function ProfileForm() {
|
|
18
|
+
const { control, register, handleSubmit } = useForm()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
22
|
+
<input {...register('email')} />
|
|
23
|
+
<DevTool control={control} /> {/* Always renders, even in production */}
|
|
24
|
+
</form>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Correct (conditionally render DevTools):**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { DevTool } from '@hookform/devtools'
|
|
33
|
+
|
|
34
|
+
function ProfileForm() {
|
|
35
|
+
const { control, register, handleSubmit } = useForm()
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
39
|
+
<input {...register('email')} />
|
|
40
|
+
{process.env.NODE_ENV === 'development' && <DevTool control={control} />}
|
|
41
|
+
</form>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Alternative (dynamic import to avoid bundle impact):**
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
const DevTool = lazy(() =>
|
|
50
|
+
import('@hookform/devtools').then((mod) => ({ default: mod.DevTool }))
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
function ProfileForm() {
|
|
54
|
+
const { control, register, handleSubmit } = useForm()
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
58
|
+
<input {...register('email')} />
|
|
59
|
+
{process.env.NODE_ENV === 'development' && (
|
|
60
|
+
<Suspense fallback={null}>
|
|
61
|
+
<DevTool control={control} />
|
|
62
|
+
</Suspense>
|
|
63
|
+
)}
|
|
64
|
+
</form>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Reference: [React Hook Form DevTools](https://react-hook-form.com/dev-tools)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Wrap FormProvider Children with React.memo
|
|
3
|
+
impact: LOW
|
|
4
|
+
impactDescription: prevents cascade re-renders from FormProvider state updates
|
|
5
|
+
tags: adv, FormProvider, memo, optimization
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Wrap FormProvider Children with React.memo
|
|
9
|
+
|
|
10
|
+
FormProvider triggers re-renders on form state updates. Wrap expensive child components with `React.memo` to prevent unnecessary re-renders when their props haven't changed.
|
|
11
|
+
|
|
12
|
+
**Incorrect (children re-render on any form state change):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function LargeForm() {
|
|
16
|
+
const methods = useForm()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<FormProvider {...methods}>
|
|
20
|
+
<form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
21
|
+
<PersonalInfoSection /> {/* Re-renders on ANY form state change */}
|
|
22
|
+
<AddressSection /> {/* Re-renders on ANY form state change */}
|
|
23
|
+
<PaymentSection /> {/* Re-renders on ANY form state change */}
|
|
24
|
+
</form>
|
|
25
|
+
</FormProvider>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function PersonalInfoSection() {
|
|
30
|
+
const { register } = useFormContext()
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<input {...register('firstName')} />
|
|
34
|
+
<input {...register('lastName')} />
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Correct (memo prevents unnecessary child re-renders):**
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
function LargeForm() {
|
|
44
|
+
const methods = useForm()
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<FormProvider {...methods}>
|
|
48
|
+
<form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
49
|
+
<PersonalInfoSection />
|
|
50
|
+
<AddressSection />
|
|
51
|
+
<PaymentSection />
|
|
52
|
+
</form>
|
|
53
|
+
</FormProvider>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const PersonalInfoSection = memo(function PersonalInfoSection() {
|
|
58
|
+
const { register } = useFormContext()
|
|
59
|
+
return (
|
|
60
|
+
<div>
|
|
61
|
+
<input {...register('firstName')} />
|
|
62
|
+
<input {...register('lastName')} />
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const AddressSection = memo(function AddressSection() {
|
|
68
|
+
const { register } = useFormContext()
|
|
69
|
+
return (
|
|
70
|
+
<div>
|
|
71
|
+
<input {...register('address.street')} />
|
|
72
|
+
<input {...register('address.city')} />
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Reference: [React Hook Form - Advanced Usage](https://react-hook-form.com/advanced-usage)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Create Test Wrapper with QueryClient and AuthProvider
|
|
3
|
+
impact: LOW
|
|
4
|
+
impactDescription: enables proper hook testing with required context providers
|
|
5
|
+
tags: adv, testing, wrapper, vitest, react-testing-library
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Create Test Wrapper with QueryClient and AuthProvider
|
|
9
|
+
|
|
10
|
+
Hook tests require proper context providers. Create a reusable wrapper function that provides QueryClient, AuthProvider, and any other required context for your forms.
|
|
11
|
+
|
|
12
|
+
**Incorrect (missing providers causes hook errors):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { renderHook } from '@testing-library/react'
|
|
16
|
+
import { useForm } from 'react-hook-form'
|
|
17
|
+
|
|
18
|
+
test('form submits correctly', () => {
|
|
19
|
+
const { result } = renderHook(() => useForm()) // May fail if form uses context
|
|
20
|
+
|
|
21
|
+
act(() => {
|
|
22
|
+
result.current.setValue('email', 'test@example.com')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
expect(result.current.getValues('email')).toBe('test@example.com')
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Correct (wrapper provides all required context):**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { renderHook, act } from '@testing-library/react'
|
|
33
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
34
|
+
import { useForm } from 'react-hook-form'
|
|
35
|
+
|
|
36
|
+
const createWrapper = () => {
|
|
37
|
+
const queryClient = new QueryClient({
|
|
38
|
+
defaultOptions: { queries: { retry: false } },
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
return function Wrapper({ children }: { children: React.ReactNode }) {
|
|
42
|
+
return (
|
|
43
|
+
<QueryClientProvider client={queryClient}>
|
|
44
|
+
{children}
|
|
45
|
+
</QueryClientProvider>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
test('form submits correctly', () => {
|
|
51
|
+
const { result } = renderHook(() => useForm(), {
|
|
52
|
+
wrapper: createWrapper(),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
act(() => {
|
|
56
|
+
result.current.setValue('email', 'test@example.com')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
expect(result.current.getValues('email')).toBe('test@example.com')
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Reference: [React Hook Form - Testing](https://react-hook-form.com/advanced-usage#TestingForm)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Provide Complete Default Objects for Field Array Operations
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: prevents partial data and validation failures
|
|
5
|
+
tags: array, useFieldArray, append, default-values
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Provide Complete Default Objects for Field Array Operations
|
|
9
|
+
|
|
10
|
+
When using `append()`, `prepend()`, `insert()`, or `update()`, always provide complete field objects with all required properties. Empty or partial objects cause validation and data inconsistencies.
|
|
11
|
+
|
|
12
|
+
**Incorrect (empty object causes undefined fields):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function TasksForm() {
|
|
16
|
+
const { control, register } = useForm<{ tasks: Task[] }>()
|
|
17
|
+
const { fields, append } = useFieldArray({ control, name: 'tasks' })
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div>
|
|
21
|
+
{fields.map((field, index) => (
|
|
22
|
+
<div key={field.id}>
|
|
23
|
+
<input {...register(`tasks.${index}.title`)} /> {/* undefined initially */}
|
|
24
|
+
<input {...register(`tasks.${index}.priority`)} /> {/* undefined initially */}
|
|
25
|
+
</div>
|
|
26
|
+
))}
|
|
27
|
+
<button type="button" onClick={() => append({})}>Add Task</button> {/* Empty object */}
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Correct (complete object with all fields):**
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
function TasksForm() {
|
|
37
|
+
const { control, register } = useForm<{ tasks: Task[] }>()
|
|
38
|
+
const { fields, append } = useFieldArray({ control, name: 'tasks' })
|
|
39
|
+
|
|
40
|
+
const addTask = () => {
|
|
41
|
+
append({
|
|
42
|
+
title: '',
|
|
43
|
+
priority: 'medium',
|
|
44
|
+
dueDate: null,
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div>
|
|
50
|
+
{fields.map((field, index) => (
|
|
51
|
+
<div key={field.id}>
|
|
52
|
+
<input {...register(`tasks.${index}.title`)} />
|
|
53
|
+
<select {...register(`tasks.${index}.priority`)}>
|
|
54
|
+
<option value="low">Low</option>
|
|
55
|
+
<option value="medium">Medium</option>
|
|
56
|
+
<option value="high">High</option>
|
|
57
|
+
</select>
|
|
58
|
+
</div>
|
|
59
|
+
))}
|
|
60
|
+
<button type="button" onClick={addTask}>Add Task</button>
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Reference: [useFieldArray](https://react-hook-form.com/docs/usefieldarray)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Separate Sequential Field Array Operations
|
|
3
|
+
impact: MEDIUM-HIGH
|
|
4
|
+
impactDescription: prevents state corruption from batched mutations
|
|
5
|
+
tags: array, useFieldArray, append, remove, sequential
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Separate Sequential Field Array Operations
|
|
9
|
+
|
|
10
|
+
Chaining `append()` and `remove()` in the same handler can cause state corruption. Defer removals to a useEffect or separate user action to allow React to process renders between operations.
|
|
11
|
+
|
|
12
|
+
**Incorrect (stacked operations cause state issues):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function ReplaceItemForm() {
|
|
16
|
+
const { control } = useForm()
|
|
17
|
+
const { fields, append, remove } = useFieldArray({ control, name: 'items' })
|
|
18
|
+
|
|
19
|
+
const replaceItem = (indexToReplace: number, newItem: Item) => {
|
|
20
|
+
remove(indexToReplace) // Remove old item
|
|
21
|
+
append(newItem) // Immediately add new - state may be stale
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
{fields.map((field, index) => (
|
|
27
|
+
<ItemRow
|
|
28
|
+
key={field.id}
|
|
29
|
+
index={index}
|
|
30
|
+
onReplace={(newItem) => replaceItem(index, newItem)}
|
|
31
|
+
/>
|
|
32
|
+
))}
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Correct (use update for replacements, or defer operations):**
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
function ReplaceItemForm() {
|
|
42
|
+
const { control } = useForm()
|
|
43
|
+
const { fields, update } = useFieldArray({ control, name: 'items' })
|
|
44
|
+
|
|
45
|
+
const replaceItem = (indexToReplace: number, newItem: Item) => {
|
|
46
|
+
update(indexToReplace, newItem) // Single atomic operation
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div>
|
|
51
|
+
{fields.map((field, index) => (
|
|
52
|
+
<ItemRow
|
|
53
|
+
key={field.id}
|
|
54
|
+
index={index}
|
|
55
|
+
onReplace={(newItem) => replaceItem(index, newItem)}
|
|
56
|
+
/>
|
|
57
|
+
))}
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Alternative (defer removal with useEffect):**
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const [pendingRemoval, setPendingRemoval] = useState<number | null>(null)
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (pendingRemoval !== null) {
|
|
70
|
+
remove(pendingRemoval)
|
|
71
|
+
setPendingRemoval(null)
|
|
72
|
+
}
|
|
73
|
+
}, [pendingRemoval, remove])
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Reference: [useFieldArray](https://react-hook-form.com/docs/usefieldarray)
|