@bovinphang/frontend-craft 2.6.0 → 2.8.0
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-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +72 -1
- package/CHANGELOG.zh-CN.md +71 -1
- package/README.md +10 -6
- package/README.openclaw.md +100 -42
- package/README.openclaw.zh-CN.md +100 -42
- package/README.zh-CN.md +10 -6
- package/agents/fec-architect.md +70 -70
- package/agents/fec-code-reviewer.md +82 -82
- package/agents/fec-debugger.md +20 -20
- package/agents/fec-design-token-mapper.md +36 -36
- package/agents/fec-doc-updater.md +13 -13
- package/agents/fec-e2e-runner.md +45 -45
- package/agents/fec-figma-implementer.md +59 -59
- package/agents/fec-performance-optimizer.md +128 -128
- package/agents/fec-refactor-cleaner.md +14 -14
- package/agents/fec-security-reviewer.md +66 -67
- package/agents/fec-test-planner.md +27 -27
- package/agents/fec-typescript-reviewer.md +88 -88
- package/agents/fec-ui-checker.md +74 -74
- package/commands/fec-debug.md +19 -19
- package/commands/fec-doc-sync.md +11 -11
- package/commands/fec-init.md +37 -38
- package/commands/fec-plan.md +58 -58
- package/commands/fec-refactor-clean.md +11 -11
- package/commands/fec-review.md +41 -41
- package/commands/fec-scaffold.md +41 -41
- package/commands/fec-tdd.md +13 -13
- package/dist/bin/frontend-craft.js +29 -27
- package/docs/example-prompts.md +84 -69
- package/docs/ja-JP/README.md +56 -52
- package/docs/ko-KR/README.md +45 -41
- package/docs/project-structure.md +19 -7
- package/docs/superpowers/plans/2026-05-29-fec-debug.md +491 -0
- package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +340 -0
- package/docs/zh-CN/example-prompts.md +84 -69
- package/docs/zh-CN/project-structure.md +14 -5
- package/docs/zh-TW/README.md +33 -29
- package/localized/zh-CN/agents/fec-architect.md +125 -0
- package/localized/zh-CN/agents/fec-code-reviewer.md +152 -0
- package/localized/zh-CN/agents/fec-debugger.md +44 -0
- package/localized/zh-CN/agents/fec-design-token-mapper.md +75 -0
- package/localized/zh-CN/agents/fec-doc-updater.md +30 -0
- package/localized/zh-CN/agents/fec-e2e-runner.md +107 -0
- package/localized/zh-CN/agents/fec-figma-implementer.md +104 -0
- package/localized/zh-CN/agents/fec-performance-optimizer.md +293 -0
- package/localized/zh-CN/agents/fec-refactor-cleaner.md +32 -0
- package/localized/zh-CN/agents/fec-security-reviewer.md +116 -0
- package/localized/zh-CN/agents/fec-test-planner.md +50 -0
- package/localized/zh-CN/agents/fec-typescript-reviewer.md +142 -0
- package/localized/zh-CN/agents/fec-ui-checker.md +120 -0
- package/localized/zh-CN/commands/fec-debug.md +30 -0
- package/localized/zh-CN/commands/fec-doc-sync.md +19 -0
- package/localized/zh-CN/commands/fec-init.md +70 -0
- package/localized/zh-CN/commands/fec-plan.md +94 -0
- package/localized/zh-CN/commands/fec-refactor-clean.md +19 -0
- package/localized/zh-CN/commands/fec-review.md +66 -0
- package/localized/zh-CN/commands/fec-scaffold.md +205 -0
- package/localized/zh-CN/commands/fec-tdd.md +21 -0
- package/localized/zh-CN/skills/TEMPLATE.md +155 -0
- package/localized/zh-CN/skills/eval_queries.json +1013 -0
- package/localized/zh-CN/skills/fec-accessibility-check/SKILL.md +39 -0
- package/localized/zh-CN/skills/fec-accessibility-check/references/report-template.md +23 -0
- package/localized/zh-CN/skills/fec-accessibility-check/references/screen-reader-testing.md +33 -0
- package/localized/zh-CN/skills/fec-alchemy/SKILL.md +74 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/absorption-plan-template.md +47 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/intake-template.md +55 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/review-checklist.md +31 -0
- package/localized/zh-CN/skills/fec-alchemy/references/methodology.md +94 -0
- package/localized/zh-CN/skills/fec-alchemy/references/originality-and-licensing.md +57 -0
- package/localized/zh-CN/skills/fec-api-integration/SKILL.md +78 -0
- package/localized/zh-CN/skills/fec-api-integration/references/integration-patterns.md +80 -0
- package/localized/zh-CN/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
- package/localized/zh-CN/skills/fec-browser-storage/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-browser-storage/references/storage-patterns.md +65 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/SKILL.md +66 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/references/rendering-patterns.md +67 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +67 -0
- package/localized/zh-CN/skills/fec-code-review/SKILL.md +143 -0
- package/localized/zh-CN/skills/fec-code-review/references/report-template.md +29 -0
- package/localized/zh-CN/skills/fec-component-testing/SKILL.md +119 -0
- package/localized/zh-CN/skills/fec-data-fetching/SKILL.md +62 -0
- package/localized/zh-CN/skills/fec-data-fetching/references/query-patterns.md +103 -0
- package/localized/zh-CN/skills/fec-debug-framework/SKILL.md +157 -0
- package/localized/zh-CN/skills/fec-debug-framework/references/report-template.md +58 -0
- package/localized/zh-CN/skills/fec-dependency-upgrade/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +56 -0
- package/localized/zh-CN/skills/fec-doc-sync/SKILL.md +39 -0
- package/localized/zh-CN/skills/fec-drawio-studio/SKILL.md +73 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/brand-icons.json +878 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/shape-index.json +83570 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/data-residency.md +27 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/schema.json +112 -0
- package/localized/zh-CN/skills/fec-e2e-testing/SKILL.md +42 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/playwright-patterns.md +95 -0
- package/localized/zh-CN/skills/fec-form-handling/SKILL.md +76 -0
- package/localized/zh-CN/skills/fec-form-handling/references/advanced-form-patterns.md +101 -0
- package/localized/zh-CN/skills/fec-image-generation/SKILL.md +80 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/localized/zh-CN/skills/fec-image-generation/references/artifact-routing.md +80 -0
- package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +74 -0
- package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
- package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
- package/localized/zh-CN/skills/fec-implement-from-design/SKILL.md +129 -0
- package/localized/zh-CN/skills/fec-implement-from-design/references/design-plan-template.md +36 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/SKILL.md +46 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +41 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
- package/localized/zh-CN/skills/fec-legacy-web-standard/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-legacy-web-standard/references/legacy-patterns.md +85 -0
- package/localized/zh-CN/skills/fec-list-virtualization/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-list-virtualization/references/virtualization-patterns.md +80 -0
- package/localized/zh-CN/skills/fec-monorepo-project-standard/SKILL.md +142 -0
- package/localized/zh-CN/skills/fec-motion-interaction/SKILL.md +73 -0
- package/localized/zh-CN/skills/fec-motion-interaction/references/motion-patterns.md +112 -0
- package/localized/zh-CN/skills/fec-nextjs-project-standard/SKILL.md +123 -0
- package/localized/zh-CN/skills/fec-nuxt-project-standard/SKILL.md +122 -0
- package/localized/zh-CN/skills/fec-performance-optimization/SKILL.md +80 -0
- package/localized/zh-CN/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
- package/localized/zh-CN/skills/fec-performance-optimization/references/report-template.md +59 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/references/manifest-and-icons.md +53 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/references/service-worker-workbox.md +68 -0
- package/localized/zh-CN/skills/fec-react-project-standard/SKILL.md +91 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
- package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +51 -0
- package/localized/zh-CN/skills/fec-refactor-clean/references/report-template.md +42 -0
- package/localized/zh-CN/skills/fec-responsive-layout/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-responsive-layout/references/responsive-layout-patterns.md +70 -0
- package/localized/zh-CN/skills/fec-route-protection/SKILL.md +135 -0
- package/localized/zh-CN/skills/fec-security-review/SKILL.md +38 -0
- package/localized/zh-CN/skills/fec-security-review/references/report-template.md +27 -0
- package/localized/zh-CN/skills/fec-security-review/references/security-checklist.md +64 -0
- package/localized/zh-CN/skills/fec-source-driven-development/SKILL.md +87 -0
- package/localized/zh-CN/skills/fec-state-management/SKILL.md +140 -0
- package/localized/zh-CN/skills/fec-state-management/references/state-patterns.md +109 -0
- package/localized/zh-CN/skills/fec-storybook-component-doc/SKILL.md +37 -0
- package/localized/zh-CN/skills/fec-storybook-component-doc/references/story-patterns.md +118 -0
- package/localized/zh-CN/skills/fec-svg-animation/SKILL.md +148 -0
- package/localized/zh-CN/skills/fec-tailwind-design-system/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +59 -0
- package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +52 -0
- package/localized/zh-CN/skills/fec-testing-strategy/SKILL.md +45 -0
- package/localized/zh-CN/skills/fec-typescript-project-standard/SKILL.md +54 -0
- package/{skills/fec-typescript-type-safety → localized/zh-CN/skills/fec-typescript-project-standard}/references/type-safety-patterns.md +1 -1
- package/{skills/fec-typescript-type-safety/SKILL.md → localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety.md} +5 -14
- package/localized/zh-CN/skills/fec-ui-design/SKILL.md +108 -0
- package/localized/zh-CN/skills/fec-ui-design/data/product-rules.json +231 -0
- package/localized/zh-CN/skills/fec-ui-design/data/stack-ui-rules.json +146 -0
- package/localized/zh-CN/skills/fec-ui-design/data/style-archetypes.json +373 -0
- package/localized/zh-CN/skills/fec-ui-design/data/ux-quality-rules.json +203 -0
- package/localized/zh-CN/skills/fec-ui-design/references/design-intelligence.md +97 -0
- package/localized/zh-CN/skills/fec-ui-design/references/master-page-overrides.md +30 -0
- package/localized/zh-CN/skills/fec-ui-design/references/pre-delivery-checklist.md +39 -0
- package/localized/zh-CN/skills/fec-ui-design/scripts/design-system.mjs +648 -0
- package/localized/zh-CN/skills/fec-validation-fix/SKILL.md +51 -0
- package/localized/zh-CN/skills/fec-validation-fix/references/report-template.md +43 -0
- package/localized/zh-CN/skills/fec-vite-project-standard/SKILL.md +83 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/SKILL.md +58 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +162 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-project-structure.md +176 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/SKILL.md +61 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/content-plan.md +38 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/theme-system.md +36 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
- package/localized/zh-CN/skills/fec-web-workers/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-web-workers/references/advanced-workers.md +54 -0
- package/localized/zh-CN/skills/fec-web-workers/references/basic-worker.md +67 -0
- package/localized/zh-CN/skills/metadata.json +1646 -0
- package/localized/zh-CN/skills/relations.json +755 -0
- package/localized/zh-CN/templates/claude/CLAUDE.md +106 -0
- package/localized/zh-CN/templates/claude/settings.json +62 -0
- package/localized/zh-CN/templates/codex/AGENTS.md +105 -0
- package/localized/zh-CN/templates/codex/config.toml +32 -0
- package/localized/zh-CN/templates/openclaw/AGENTS.md +101 -0
- package/localized/zh-CN/templates/openclaw/OPENCLAW-CONFIG.md +12 -0
- package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +54 -0
- package/localized/zh-CN/templates/shared/rules/fec-api-layer.md +99 -0
- package/localized/zh-CN/templates/shared/rules/fec-ci-cd.md +40 -0
- package/localized/zh-CN/templates/shared/rules/fec-code-comments.md +33 -0
- package/localized/zh-CN/templates/shared/rules/fec-design-system.md +72 -0
- package/localized/zh-CN/templates/shared/rules/fec-error-handling.md +56 -0
- package/localized/zh-CN/templates/shared/rules/fec-git-conventions.md +73 -0
- package/localized/zh-CN/templates/shared/rules/fec-i18n.md +64 -0
- package/localized/zh-CN/templates/shared/rules/fec-naming-conventions.md +120 -0
- package/localized/zh-CN/templates/shared/rules/fec-performance.md +101 -0
- package/localized/zh-CN/templates/shared/rules/fec-react.md +82 -0
- package/localized/zh-CN/templates/shared/rules/fec-refactoring.md +47 -0
- package/localized/zh-CN/templates/shared/rules/fec-rendering-patterns.md +40 -0
- package/localized/zh-CN/templates/shared/rules/fec-responsive-design.md +50 -0
- package/localized/zh-CN/templates/shared/rules/fec-source-driven-development.md +31 -0
- package/localized/zh-CN/templates/shared/rules/fec-state-management.md +60 -0
- package/localized/zh-CN/templates/shared/rules/fec-testing.md +98 -0
- package/localized/zh-CN/templates/shared/rules/fec-typescript.md +112 -0
- package/localized/zh-CN/templates/shared/rules/fec-vue.md +64 -0
- package/localized/zh-CN/templates/shared/rules/fec-working-modes.md +50 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +4 -3
- package/skills/TEMPLATE.md +74 -74
- package/skills/eval_queries.json +717 -619
- package/skills/fec-accessibility-check/SKILL.md +21 -21
- package/skills/fec-accessibility-check/references/report-template.md +12 -12
- package/skills/fec-accessibility-check/references/screen-reader-testing.md +24 -24
- package/skills/fec-alchemy/SKILL.md +50 -50
- package/skills/fec-alchemy/assets/absorption-plan-template.md +32 -32
- package/skills/fec-alchemy/assets/intake-template.md +55 -55
- package/skills/fec-alchemy/assets/review-checklist.md +23 -23
- package/skills/fec-alchemy/references/methodology.md +66 -66
- package/skills/fec-alchemy/references/originality-and-licensing.md +42 -42
- package/skills/fec-api-integration/SKILL.md +61 -61
- package/skills/fec-api-integration/references/integration-patterns.md +30 -30
- package/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
- package/skills/fec-browser-storage/SKILL.md +16 -16
- package/skills/fec-browser-storage/references/storage-patterns.md +16 -16
- package/skills/fec-canvas-threejs/SKILL.md +21 -21
- package/skills/fec-canvas-threejs/references/rendering-patterns.md +10 -10
- package/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +37 -37
- package/skills/fec-code-review/SKILL.md +94 -94
- package/skills/fec-code-review/references/report-template.md +13 -13
- package/skills/fec-component-testing/SKILL.md +39 -39
- package/skills/fec-data-fetching/SKILL.md +16 -16
- package/skills/fec-data-fetching/references/query-patterns.md +27 -27
- package/skills/fec-debug-framework/SKILL.md +95 -95
- package/skills/fec-debug-framework/references/report-template.md +34 -34
- package/skills/fec-dependency-upgrade/SKILL.md +17 -17
- package/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +31 -31
- package/skills/fec-doc-sync/SKILL.md +23 -23
- package/skills/fec-drawio-studio/SKILL.md +73 -0
- package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
- package/skills/fec-drawio-studio/data/brand-icons.json +878 -0
- package/skills/fec-drawio-studio/data/shape-index.json +83570 -0
- package/skills/fec-drawio-studio/references/data-residency.md +27 -0
- package/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
- package/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
- package/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
- package/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
- package/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
- package/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
- package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
- package/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
- package/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
- package/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
- package/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
- package/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
- package/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
- package/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
- package/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
- package/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
- package/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
- package/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
- package/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
- package/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
- package/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
- package/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
- package/skills/fec-drawio-studio/styles/schema.json +112 -0
- package/skills/fec-e2e-testing/SKILL.md +24 -22
- package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
- package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
- package/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
- package/skills/fec-e2e-testing/references/playwright-patterns.md +6 -6
- package/skills/fec-form-handling/SKILL.md +21 -21
- package/skills/fec-form-handling/references/advanced-form-patterns.md +41 -41
- package/skills/fec-image-generation/SKILL.md +81 -0
- package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/skills/fec-image-generation/references/artifact-routing.md +80 -0
- package/skills/fec-image-generation/references/diagram-workflows.md +74 -0
- package/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
- package/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
- package/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
- package/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
- package/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
- package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
- package/skills/fec-implement-from-design/SKILL.md +81 -74
- package/skills/fec-implement-from-design/references/design-plan-template.md +16 -16
- package/skills/fec-legacy-to-modern-migration/SKILL.md +29 -173
- package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
- package/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +37 -37
- package/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
- package/skills/fec-legacy-web-standard/SKILL.md +17 -17
- package/skills/fec-legacy-web-standard/references/legacy-patterns.md +16 -16
- package/skills/fec-list-virtualization/SKILL.md +16 -16
- package/skills/fec-list-virtualization/references/virtualization-patterns.md +31 -31
- package/skills/fec-monorepo-project-standard/SKILL.md +52 -52
- package/skills/fec-motion-interaction/SKILL.md +51 -44
- package/skills/fec-motion-interaction/references/motion-patterns.md +11 -11
- package/skills/fec-nextjs-project-standard/SKILL.md +64 -58
- package/skills/fec-nuxt-project-standard/SKILL.md +57 -57
- package/skills/fec-performance-optimization/SKILL.md +54 -50
- package/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
- package/skills/fec-performance-optimization/references/report-template.md +34 -28
- package/skills/fec-pwa-implementation/SKILL.md +17 -17
- package/skills/fec-pwa-implementation/references/manifest-and-icons.md +12 -12
- package/skills/fec-pwa-implementation/references/service-worker-workbox.md +13 -13
- package/skills/fec-react-project-standard/SKILL.md +72 -64
- package/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
- package/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
- package/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
- package/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
- package/skills/fec-refactor-clean/SKILL.md +30 -30
- package/skills/fec-refactor-clean/references/report-template.md +23 -23
- package/skills/fec-responsive-layout/SKILL.md +17 -17
- package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +39 -28
- package/skills/fec-route-protection/SKILL.md +26 -26
- package/skills/fec-security-review/SKILL.md +20 -20
- package/skills/fec-security-review/references/report-template.md +12 -12
- package/skills/fec-security-review/references/security-checklist.md +27 -27
- package/skills/fec-source-driven-development/SKILL.md +66 -40
- package/skills/fec-state-management/SKILL.md +34 -34
- package/skills/fec-state-management/references/state-patterns.md +19 -19
- package/skills/fec-storybook-component-doc/SKILL.md +19 -19
- package/skills/fec-storybook-component-doc/references/story-patterns.md +12 -12
- package/skills/fec-svg-animation/SKILL.md +32 -32
- package/skills/fec-tailwind-design-system/SKILL.md +17 -17
- package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +36 -32
- package/skills/fec-tdd-workflow/SKILL.md +28 -28
- package/skills/fec-testing-strategy/SKILL.md +29 -29
- package/skills/fec-typescript-project-standard/SKILL.md +54 -0
- package/skills/fec-typescript-project-standard/references/type-safety-patterns.md +102 -0
- package/skills/fec-typescript-project-standard/references/type-safety.md +148 -0
- package/skills/fec-ui-design/SKILL.md +90 -72
- package/skills/fec-ui-design/data/style-archetypes.json +40 -0
- package/skills/fec-ui-design/data/ux-quality-rules.json +35 -0
- package/skills/fec-ui-design/references/design-intelligence.md +81 -21
- package/skills/fec-ui-design/references/master-page-overrides.md +15 -15
- package/skills/fec-ui-design/references/pre-delivery-checklist.md +38 -32
- package/skills/fec-ui-design/scripts/design-system.mjs +119 -1
- package/skills/fec-validation-fix/SKILL.md +26 -26
- package/skills/fec-validation-fix/references/report-template.md +25 -25
- package/skills/fec-vite-project-standard/SKILL.md +39 -39
- package/skills/fec-vue3-project-standard/SKILL.md +39 -30
- package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +163 -0
- package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
- package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +177 -0
- package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
- package/skills/fec-web-video-presentation/SKILL.md +61 -0
- package/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
- package/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
- package/skills/fec-web-video-presentation/references/content-plan.md +38 -0
- package/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
- package/skills/fec-web-video-presentation/references/theme-system.md +36 -0
- package/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
- package/skills/fec-web-workers/SKILL.md +16 -16
- package/skills/fec-web-workers/references/advanced-workers.md +13 -13
- package/skills/fec-web-workers/references/basic-worker.md +8 -8
- package/skills/metadata.json +402 -220
- package/skills/relations.json +120 -25
- package/templates/claude/CLAUDE.md +60 -60
- package/templates/codex/AGENTS.md +76 -76
- package/templates/codex/config.toml +4 -4
- package/templates/openclaw/AGENTS.md +68 -68
- package/templates/openclaw/OPENCLAW-CONFIG.md +8 -8
- package/templates/shared/rules/fec-agent-workflow.md +40 -40
- package/templates/shared/rules/fec-api-layer.md +52 -52
- package/templates/shared/rules/fec-ci-cd.md +29 -117
- package/templates/shared/rules/fec-code-comments.md +22 -22
- package/templates/shared/rules/fec-design-system.md +65 -241
- package/templates/shared/rules/fec-error-handling.md +41 -185
- package/templates/shared/rules/fec-git-conventions.md +42 -42
- package/templates/shared/rules/fec-i18n.md +48 -96
- package/templates/shared/rules/fec-naming-conventions.md +91 -91
- package/templates/shared/rules/fec-performance.md +78 -78
- package/templates/shared/rules/fec-react.md +58 -58
- package/templates/shared/rules/fec-refactoring.md +34 -30
- package/templates/shared/rules/fec-rendering-patterns.md +40 -183
- package/templates/shared/rules/fec-responsive-design.md +37 -214
- package/templates/shared/rules/fec-source-driven-development.md +22 -22
- package/templates/shared/rules/fec-state-management.md +45 -148
- package/templates/shared/rules/fec-testing.md +64 -64
- package/templates/shared/rules/fec-typescript.md +98 -341
- package/templates/shared/rules/fec-vue.md +42 -42
- package/templates/shared/rules/fec-working-modes.md +34 -34
- package/skills/fec-e2e-testing/references/e2e-advanced.md +0 -176
- package/skills/fec-react-project-standard/references/react-project-details.md +0 -642
- package/skills/fec-vue3-project-standard/references/vue3-project-details.md +0 -547
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# React project structure and component boundaries
|
|
2
|
+
|
|
3
|
+
## Project structure (recommended reference)
|
|
4
|
+
|
|
5
|
+
The following is the industry's best practice structure for medium and large React projects, tailored according to the actual situation of the project:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
src/
|
|
9
|
+
├── app/ # Application entry and global configuration
|
|
10
|
+
│ ├── App.tsx # Root component (Provider combination)
|
|
11
|
+
│ ├── routes.tsx # Routing configuration
|
|
12
|
+
│ └── providers.tsx # Global Provider assembly
|
|
13
|
+
│
|
|
14
|
+
├── pages/ # Page components (one-to-one correspondence with routing)
|
|
15
|
+
│ ├── Dashboard/
|
|
16
|
+
│ │ ├── DashboardPage.tsx
|
|
17
|
+
│ │ ├── components/ # Page private components
|
|
18
|
+
│ │ └── hooks/ # Page private hooks
|
|
19
|
+
│ ├── UserList/
|
|
20
|
+
│ └── Settings/
|
|
21
|
+
│
|
|
22
|
+
├── layouts/ # Layout component
|
|
23
|
+
│ ├── MainLayout.tsx # Main layout (sidebar + top bar + content area)
|
|
24
|
+
│ ├── AuthLayout.tsx # Login/registration page layout
|
|
25
|
+
│ └── BlankLayout.tsx # Blank layout (error page, etc.)
|
|
26
|
+
│
|
|
27
|
+
├── features/ # Function modules (divided by business areas)
|
|
28
|
+
│ ├── auth/
|
|
29
|
+
│ │ ├── components/ # Module components
|
|
30
|
+
│ │ ├── hooks/ # module hooks
|
|
31
|
+
│ │ ├── api.ts # Module API call
|
|
32
|
+
│ │ ├── types.ts # Module type definition
|
|
33
|
+
│ │ ├── constants.ts # Module constants
|
|
34
|
+
│ │ └── index.ts # Module publicly exported
|
|
35
|
+
│ └── order/
|
|
36
|
+
│
|
|
37
|
+
├── components/ # Globally shared UI components
|
|
38
|
+
│ ├── Button/
|
|
39
|
+
│ │ ├── Button.tsx
|
|
40
|
+
│ │ ├── Button.styles.css
|
|
41
|
+
│ │ └── __tests__/
|
|
42
|
+
│ ├── Modal/
|
|
43
|
+
│ ├── Form/
|
|
44
|
+
│ └── ErrorBoundary/ # Thin wrapper (function component) for react-error-boundary etc.
|
|
45
|
+
│
|
|
46
|
+
├── hooks/ # Global shared hooks
|
|
47
|
+
│ ├── useAuth.ts
|
|
48
|
+
│ ├── useDebounce.ts
|
|
49
|
+
│ └── useMediaQuery.ts
|
|
50
|
+
│
|
|
51
|
+
├── services/ # API base layer
|
|
52
|
+
│ ├── request.ts # Axios/fetch instance and interceptor
|
|
53
|
+
│ └── endpoints/ # API endpoint definition (such as split by field)
|
|
54
|
+
│
|
|
55
|
+
├── stores/ # Global status management
|
|
56
|
+
│ ├── authStore.ts
|
|
57
|
+
│ └── uiStore.ts
|
|
58
|
+
│
|
|
59
|
+
├── locales/ # International language pack
|
|
60
|
+
│ ├── zh-CN.json # Simplified Chinese
|
|
61
|
+
│ ├── en-US.json # English
|
|
62
|
+
│ └── index.ts # i18n instance initialization (i18next / react-intl)
|
|
63
|
+
│
|
|
64
|
+
├── assets/ # Static resources
|
|
65
|
+
│ ├── images/ # Pictures (PNG, JPG, WebP)
|
|
66
|
+
│ ├── icons/ # SVG icon
|
|
67
|
+
│ └── fonts/ # Custom fonts
|
|
68
|
+
│
|
|
69
|
+
├── config/ # Application configuration
|
|
70
|
+
│ ├── env.ts # Typed encapsulation of environment variables
|
|
71
|
+
│ └── features.ts # Feature Flags Management
|
|
72
|
+
│
|
|
73
|
+
├── types/ # Global shared types
|
|
74
|
+
│ ├── api.ts # API response/request common type
|
|
75
|
+
│ ├── models.ts #Business entity type
|
|
76
|
+
│ └── global.d.ts # Global type extension (picture module declaration, etc.)
|
|
77
|
+
│
|
|
78
|
+
├── utils/ # Pure utility function
|
|
79
|
+
│ ├── format.ts # Date, number, currency formatting
|
|
80
|
+
│ ├── validators.ts # Form validation rules
|
|
81
|
+
│ └── storage.ts # LocalStorage / SessionStorage package
|
|
82
|
+
│
|
|
83
|
+
├── styles/ # Global styles and themes
|
|
84
|
+
│ ├── global.css # Global basic style (reset/normalize)
|
|
85
|
+
│ ├── variables.css # CSS variables (color, spacing, font size)
|
|
86
|
+
│ ├── breakpoints.ts # Responsive breakpoint constants
|
|
87
|
+
│ └── themes/ # theme definition
|
|
88
|
+
│ ├── light.css # Light theme variable
|
|
89
|
+
│ ├── dark.css # Dark theme variable
|
|
90
|
+
│ └── index.ts # theme switching logic
|
|
91
|
+
│
|
|
92
|
+
└── constants/ # Global constants
|
|
93
|
+
├── routes.ts #Routing path constants
|
|
94
|
+
└── config.ts #Business constants (paging size, timeout, etc.)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Key Principles
|
|
98
|
+
|
|
99
|
+
- `pages/` does route mapping and page arrangement, and does not carry large pieces of reusable business logic.
|
|
100
|
+
- `layouts/` is responsible for the page skeleton and layout container, referenced by the routing configuration
|
|
101
|
+
- `features/` is divided according to business areas, and the module should be as self-contained as possible
|
|
102
|
+
- `components/` only contains common components that are reused across pages and modules
|
|
103
|
+
- `hooks/` only puts global general hooks; business hooks are put back to the corresponding feature or page first
|
|
104
|
+
- `locales/` stores language pack JSON files, use `t('key')` in the component instead of hard-coded copy
|
|
105
|
+
- `assets/` stores static resources, SVG is preferred for icons, and WebP/AVIF is preferred for images.
|
|
106
|
+
- `services/` is responsible for requesting infrastructure and does not stack business details
|
|
107
|
+
- `config/` uniformly encapsulates environment variables and feature switches, prohibiting direct reading of `import.meta.env` in components
|
|
108
|
+
- `styles/` and theme variables are managed uniformly to avoid colors and sizes being scattered in business code
|
|
109
|
+
- Each module controls the public API through `index.ts` to avoid deep path imports
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Component and module layering
|
|
114
|
+
|
|
115
|
+
Recommended layering:
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
Page components (Pages) → route mapping, layout combination, page arrangement
|
|
119
|
+
└── Container/orchestration layer → data acquisition, status organization, event orchestration
|
|
120
|
+
└── Business components → Domain logic display
|
|
121
|
+
└── Common components → No business coupling, reusable across modules
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### When to put it in `pages/`
|
|
125
|
+
|
|
126
|
+
Suitable for:
|
|
127
|
+
|
|
128
|
+
- Routing entry component
|
|
129
|
+
- Page level layout combination
|
|
130
|
+
- Page private lightweight orchestration logic
|
|
131
|
+
|
|
132
|
+
Not suitable for:
|
|
133
|
+
|
|
134
|
+
- A lot of domain logic
|
|
135
|
+
- Complex business blocks that can be reused on multiple pages
|
|
136
|
+
- API/hooks/types that are strongly bound to a certain business domain
|
|
137
|
+
|
|
138
|
+
### When to put it in `features/`
|
|
139
|
+
|
|
140
|
+
Suitable for:
|
|
141
|
+
|
|
142
|
+
- Components, hooks, apis, and types of a certain business domain
|
|
143
|
+
- Logic that can be shared by multiple pages but has business semantics
|
|
144
|
+
- Self-contained implementation of a complete business unit
|
|
145
|
+
|
|
146
|
+
### When to put it in `components/`
|
|
147
|
+
|
|
148
|
+
Suitable for:
|
|
149
|
+
|
|
150
|
+
- Common UI such as buttons, pop-up windows, form items, table shells, empty states, error states, etc.
|
|
151
|
+
- Components that have nothing to do with specific business and can be reused across modules
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Component design specifications
|
|
156
|
+
|
|
157
|
+
- Use **Functional Components**, Hooks and TypeScript; **Do not** add new class components (Error Boundary uses libraries such as `react-error-boundary`, see below)
|
|
158
|
+
- **Single file size** and splitting principles can be found in `templates/shared/rules/fec-react.md` "**Component file size**" (approximately 300 lines is preferred, if it exceeds 500 lines or is too complex, sub-components, Hooks, utils, and types will be split)
|
|
159
|
+
- Keep components with single responsibilities and composable
|
|
160
|
+
- Extract reusable logic into hooks
|
|
161
|
+
- Prioritize the use of controlled component APIs in appropriate scenarios
|
|
162
|
+
- props are clearly defined and typed
|
|
163
|
+
- Prioritize reuse of existing design system components
|
|
164
|
+
- Maintain accessibility with keyboard interaction
|
|
165
|
+
- Avoid deep JSX nesting and duplicate branches
|
|
166
|
+
- Do not store additional state for deducible values
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
## Component directory suggestions
|
|
172
|
+
|
|
173
|
+
When the component complexity is low, only one file can be kept.
|
|
174
|
+
When a component contains styles, subcomponents, hooks, and tests, it is recommended to use the following structure:
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
ComponentName/
|
|
178
|
+
├── ComponentName.tsx
|
|
179
|
+
├── ComponentName.types.ts
|
|
180
|
+
├── ComponentName.styles.css
|
|
181
|
+
├── hooks/
|
|
182
|
+
│ └── useComponentLogic.ts
|
|
183
|
+
├── components/
|
|
184
|
+
│ └── SubComponent.tsx
|
|
185
|
+
└── __tests__/
|
|
186
|
+
└── ComponentName.spec.tsx
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Description:
|
|
190
|
+
|
|
191
|
+
- Split `ComponentName.types.ts` when the type is complex
|
|
192
|
+
- Split `hooks/` when there is local logic reuse
|
|
193
|
+
- When the subcomponent is only used inside the current component, it is placed in the current directory `components/`
|
|
194
|
+
- Whether the test should be placed nearby should follow the existing protocols of the warehouse
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# React quality patterns
|
|
2
|
+
|
|
3
|
+
## Style access
|
|
4
|
+
|
|
5
|
+
This skill does not enforce a specific style scheme and follows the current status of the warehouse by default.
|
|
6
|
+
|
|
7
|
+
Please note when adapting:
|
|
8
|
+
|
|
9
|
+
- Tailwind project continues to use Tailwind
|
|
10
|
+
- CSS Modules projects keep naming consistent with file organization
|
|
11
|
+
- The styled-components project continues to follow its pattern
|
|
12
|
+
- Theme, color, font size, spacing, etc. give priority to reusing warehouse token / CSS variables
|
|
13
|
+
- Avoid hardcoding a large number of visual constants within the component
|
|
14
|
+
- Disable inline styles (except dynamic values)
|
|
15
|
+
- Responsive processing must be consistent with the project breakpoint agreement
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Comment specifications
|
|
20
|
+
|
|
21
|
+
- **Prefer using Chinese**: When explaining "why this is done", business constraints, boundary conditions, and non-obvious trade-offs, give priority to writing comments in Chinese to make it easier for the team and business parties to read.
|
|
22
|
+
- **Exception when consistent with the code language**: When connecting third-party protocol field names, HTTP headers, and English terms in specifications, English proper nouns can be retained in the comments, and Chinese and English descriptions can be given when necessary.
|
|
23
|
+
- **Less but more precise**: Can express clear logic through clear naming and types without writing nonsense comments; complex branches, temporary compatibility, and performance trade-offs must be clearly stated.
|
|
24
|
+
- **Public API**: The external contract of modules or hooks can use JSDoc (`@param` / `@returns` / `@example`). The instructions can be in Chinese, unless the warehouse requires English.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## TypeScript Specification
|
|
29
|
+
|
|
30
|
+
Common TypeScript project rules are taken care of by `fec-typescript-project-standard`, including `tsconfig`, strictness, DTO / view model boundaries, `unknown` narrowing, public API types, declared artifacts, and type tests.
|
|
31
|
+
|
|
32
|
+
The React specification only supplements components, Props, events and TSX generic writing; complex type modeling or cross-framework type contracts are first offloaded to `fec-typescript-project-standard`.
|
|
33
|
+
|
|
34
|
+
### React project supplementary conventions
|
|
35
|
+
|
|
36
|
+
- Props interface naming: `ComponentNameProps`
|
|
37
|
+
- Event handling function: `handle` prefix (such as `handleClick`)
|
|
38
|
+
- Callback Props: `on` prefix (such as `onChange`, `onSubmit`)
|
|
39
|
+
- Components give priority to writing explicit props and return value types (`JSX.Element` / `React.ReactElement`) to avoid behavioral differences such as relying on the implicit `children` of `React.FC`
|
|
40
|
+
- Generic components use `<T>` constraints to maintain call-site type derivation; callback and event types preferentially use DOM/React’s own types (such as `React.ChangeEvent<HTMLInputElement>`)
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
interface TableProps<T extends Record<string, unknown>> {
|
|
44
|
+
data: T[];
|
|
45
|
+
columns: ColumnDef<T>[];
|
|
46
|
+
onRowClick?: (row: T) => void;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Test specifications
|
|
53
|
+
|
|
54
|
+
### Content that should be covered first
|
|
55
|
+
|
|
56
|
+
- Core interaction behaviors (click, input, submit)
|
|
57
|
+
- Conditional rendering (loading/error/empty/data)
|
|
58
|
+
- Return values and side effects of key hooks
|
|
59
|
+
- API call mock and module-level integration testing
|
|
60
|
+
|
|
61
|
+
### Recommended style
|
|
62
|
+
|
|
63
|
+
- Test user behavior, not implementation details
|
|
64
|
+
- Prioritize using `screen.getByRole`, `getByLabelText`
|
|
65
|
+
- Avoid writing brittle tests around internal state
|
|
66
|
+
- Only measure key behaviors and do not mechanically pursue coverage figures
|
|
67
|
+
|
|
68
|
+
### Example
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
describe("UserForm", () => {
|
|
72
|
+
it("should submit with valid data", async () => {
|
|
73
|
+
const onSubmit = vi.fn();
|
|
74
|
+
render(<UserForm onSubmit={onSubmit} />);
|
|
75
|
+
|
|
76
|
+
await userEvent.type(screen.getByLabelText("username"), "test");
|
|
77
|
+
await userEvent.click(screen.getByRole("button", { name: "Submit" }));
|
|
78
|
+
|
|
79
|
+
expect(onSubmit).toHaveBeenCalledWith({ username: "test" });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should show error on invalid input", async () => {
|
|
83
|
+
render(<UserForm onSubmit={vi.fn()} />);
|
|
84
|
+
await userEvent.click(screen.getByRole("button", { name: "Submit" }));
|
|
85
|
+
expect(screen.getByText("Username cannot be empty")).toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Common anti-patterns
|
|
94
|
+
|
|
95
|
+
Avoid:
|
|
96
|
+
|
|
97
|
+
- prop drilling is too deep without considering combination or partial encapsulation
|
|
98
|
+
- Excessive use of context for local issues
|
|
99
|
+
- Stuff data requests, view rendering, and imperative DOM operations into one file
|
|
100
|
+
- Do things in useEffect that can be done in event handlers
|
|
101
|
+
- Use `useEffect + setState` to simulate derived values that could be calculated directly
|
|
102
|
+
- Push all states to the global store
|
|
103
|
+
- Put business coupling components in `components/`
|
|
104
|
+
- Directly bypass the module export and import from the feature deep path
|
|
105
|
+
- There is no obvious benefit but complex optimization is done in advance
|
|
106
|
+
- **New class component** or handwritten class Error Boundary (should function component + `react-error-boundary`, etc.)
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Output checklist
|
|
111
|
+
|
|
112
|
+
When outputting React code or solutions, at least check:
|
|
113
|
+
|
|
114
|
+
- [ ] Whether to align the existing contracts of the warehouse first
|
|
115
|
+
- [ ] Page / feature / Is the boundary of common components clear?
|
|
116
|
+
- [ ] Whether the directory structure matches the module complexity
|
|
117
|
+
- [ ] Props type is complete and clear
|
|
118
|
+
- [ ] Whether explanatory comments should be given priority in Chinese and to the point
|
|
119
|
+
- [ ] Whether reusable logic has been extracted into hooks
|
|
120
|
+
- [ ] loading / error / empty / data status is complete
|
|
121
|
+
- [ ] Whether the API layer has type constraints and unified error handling
|
|
122
|
+
- [ ] Whether complex DTO, external data narrowing, public types or `tsconfig` issues have been offloaded to `fec-typescript-project-standard`
|
|
123
|
+
- [ ] Whether status management complies with the proximity principle
|
|
124
|
+
- [ ] Whether lazy loading is considered for routing-level or heavy-duty modules
|
|
125
|
+
- [ ] Whether the style scheme is consistent with the warehouse
|
|
126
|
+
- [ ] Whether key behaviors are covered by tests
|
|
127
|
+
- [ ] Key modules have been wrapped with **`react-error-boundary`** (etc.), and no hand-written class component Boundary
|
|
128
|
+
- [ ] Whether the long list evaluates virtualization; whether the pop-up window/composite component has keyboard and focus conventions
|
|
129
|
+
- [ ] Whether unnecessary new dependencies or new paradigms are introduced
|
|
130
|
+
|
|
131
|
+
---
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# React runtime patterns
|
|
2
|
+
|
|
3
|
+
## Common UI and status mode
|
|
4
|
+
|
|
5
|
+
The following patterns can be used in comparison with other chapters of this skill (Hooks, state management, performance optimization, error handling); **Select based on business complexity and team familiarity** to avoid patterns for pattern's sake. The ideas refer to common React front-end pattern practices in the industry (such as component combination, composite components, performance and accessibility, etc.).
|
|
6
|
+
|
|
7
|
+
### Composition is better than inheritance
|
|
8
|
+
|
|
9
|
+
- Use **small subcomponents** + `children` / explicit props to assemble the interface instead of building a class inheritance hierarchy in React.
|
|
10
|
+
- Example: `Card` + `CardHeader` + `CardBody`, composed by the consumer, rather than one giant `Card` branched with a lot of boolean props.
|
|
11
|
+
|
|
12
|
+
### Compound Components
|
|
13
|
+
|
|
14
|
+
- The root component provides internal state (such as current Tab, open/closed) to child components through **Context**.
|
|
15
|
+
- The subcomponent **throws an error or asserts** when `useContext` is empty, making it clear that it "must be used within the Provider tree".
|
|
16
|
+
- API surfaces remain readable: `<Tabs><TabList><Tab /></TabList></Tabs>`.
|
|
17
|
+
|
|
18
|
+
### Render Props/Functionator
|
|
19
|
+
|
|
20
|
+
- Applicable: Encapsulate **data acquisition and three-state** (loading / error / data), and hand over **rendering decision** to the parent.
|
|
21
|
+
- Choose one of the two with **Custom Hook**: `useXxx()` + ordinary components are more intuitive in most scenarios; only keep Render Props when strong constraints on "same-layer rendering logic" are required.
|
|
22
|
+
|
|
23
|
+
### Context + useReducer
|
|
24
|
+
|
|
25
|
+
- Suitable for **moderate complexity, multi-subtree sharing** client state, and updates can be reduced to explicit `action`.
|
|
26
|
+
- Avoid stuffing large objects that change frequently into the top-level Context; server-side data still takes priority **React Query / SWR**.
|
|
27
|
+
- Large global business status continues to use the **Zusand / Redux Toolkit / Jotai** selected by the warehouse.
|
|
28
|
+
|
|
29
|
+
### Form
|
|
30
|
+
|
|
31
|
+
- Controlled fields + validation error objects are a feasible implementation; medium and large forms are given priority **React Hook Form** (or Formik) + **Zod**, and complex form values, DTO and validation type contracts are offloaded to `fec-typescript-project-standard`.
|
|
32
|
+
- Avoid huge `useState` form objects and repeated validation logic in a single component, detachable field subcomponents or extract `useFormSchema`.
|
|
33
|
+
|
|
34
|
+
### Error Boundary
|
|
35
|
+
|
|
36
|
+
- **Don't** handwrite Error Boundary in the form of React **class component** in business code; uniformly use **`react-error-boundary`** (or a similar library recognized by the team) to render failure at the **module boundary** (consistent with "Error Handling" and `error-handling.md` in this chapter).
|
|
37
|
+
- Use `FallbackComponent` and `resetErrorBoundary` to provide "retry"; **log reporting** is placed in the library's **`onError`** (waiting for callbacks), and production code avoids long-term dependence on `console.log` (see TypeScript rules).
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Animation and Transition
|
|
41
|
+
|
|
42
|
+
- List entry and exit can be done using **Framer Motion**'s `AnimatePresence` + `key`, or CSS `transition`; note that reduced layout jitter and `prefers-reduced-motion` (when consistent with accessibility policies).
|
|
43
|
+
|
|
44
|
+
### Accessibility and Focus
|
|
45
|
+
|
|
46
|
+
- Customized drop-downs, tabs, etc.: **`role` / `aria-*`**, **Direction keys / Enter / Escape** Behavior and focus rings are visible.
|
|
47
|
+
- Pop-up window: Move the focus into the dialog box when it is opened, and **restore** when it is closed to trigger the element focus; **`focus-trap-react`** or similar solutions can be used to complement the `fec-accessibility-check` skill.
|
|
48
|
+
|
|
49
|
+
### Next.js and server-side components
|
|
50
|
+
|
|
51
|
+
- **App Router, Server Components, server-side data acquisition and caching** see **`fec-nextjs-project-standard`**; the client interaction mode is still subject to this chapter and the Hooks specification.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Hooks design pattern
|
|
57
|
+
|
|
58
|
+
### Suitable for scenarios where custom Hooks are drawn
|
|
59
|
+
|
|
60
|
+
- Data acquisition and three-state management
|
|
61
|
+
- Form status logic
|
|
62
|
+
- Paging, filtering, sorting and arrangement
|
|
63
|
+
- Event monitoring and side effect cleanup
|
|
64
|
+
- Interaction logic that can be reused in multiple components
|
|
65
|
+
|
|
66
|
+
### Recommended principles
|
|
67
|
+
|
|
68
|
+
- Uniformly use `use` prefix naming
|
|
69
|
+
- Return objects instead of arrays to facilitate on-demand destructuring and enhance readability and scalability
|
|
70
|
+
- State and behavior are encapsulated together
|
|
71
|
+
- Hook internal processing `loading/error/data`
|
|
72
|
+
- Expose a clear minimal interface to the outside world without leaking irrelevant internal details
|
|
73
|
+
|
|
74
|
+
### Example
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
function useUserList(params: QueryParams) {
|
|
78
|
+
const [data, setData] = useState<User[]>([]);
|
|
79
|
+
const [loading, setLoading] = useState(false);
|
|
80
|
+
const [error, setError] = useState<Error | null>(null);
|
|
81
|
+
|
|
82
|
+
const fetch = useCallback(async () => {
|
|
83
|
+
setLoading(true);
|
|
84
|
+
setError(null);
|
|
85
|
+
try {
|
|
86
|
+
const res = await getUserList(params);
|
|
87
|
+
setData(res.list);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
setError(e as Error);
|
|
90
|
+
} finally {
|
|
91
|
+
setLoading(false);
|
|
92
|
+
}
|
|
93
|
+
}, [params]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
fetch();
|
|
97
|
+
}, [fetch]);
|
|
98
|
+
|
|
99
|
+
return { data, loading, error, refetch: fetch };
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Hook usage principles
|
|
104
|
+
|
|
105
|
+
- `useEffect` must have correct dependencies and cleanup logic
|
|
106
|
+
- `useMemo` / `useCallback` Don’t overuse it, add it only when stable references are really important
|
|
107
|
+
- Don't call hooks in conditional branches or loops
|
|
108
|
+
- When React Query / SWR has been introduced, data requests go through these libraries first instead of recreating a cache layer yourself.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Routing organization
|
|
113
|
+
|
|
114
|
+
### Recommended method
|
|
115
|
+
|
|
116
|
+
- Centralized management of routing configuration
|
|
117
|
+
- Path constantization
|
|
118
|
+
- Lazy loading of page components on demand
|
|
119
|
+
- Permission control is placed in the guard layer instead of scattered within the page components
|
|
120
|
+
- Paging, filtering, sorting, etc. URL driver status is synchronized with the address bar first
|
|
121
|
+
|
|
122
|
+
### Example
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
const routes: RouteObject[] = [
|
|
126
|
+
{
|
|
127
|
+
path: "/",
|
|
128
|
+
element: <MainLayout />,
|
|
129
|
+
children: [
|
|
130
|
+
{ index: true, element: <DashboardPage /> },
|
|
131
|
+
{ path: "users", element: <UserListPage /> },
|
|
132
|
+
{ path: "users/:id", element: <UserDetailPage /> },
|
|
133
|
+
{ path: "settings", element: <SettingsPage /> },
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{ path: "/login", element: <LoginPage /> },
|
|
137
|
+
{ path: "*", element: <NotFoundPage /> },
|
|
138
|
+
];
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
const UserListPage = lazy(() => import("@/pages/UserList/UserListPage"));
|
|
143
|
+
|
|
144
|
+
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
|
145
|
+
const { isAuthenticated } = useAuth();
|
|
146
|
+
if (!isAuthenticated) return <Navigate to="/login" replace />;
|
|
147
|
+
return <>{children}</>;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Status management selection
|
|
154
|
+
|
|
155
|
+
| Status type | Recommended solution |
|
|
156
|
+
| ------------------ | ------------------------------------------------- |
|
|
157
|
+
| Temporary UI state within the component | `useState` / `useReducer` |
|
|
158
|
+
| Sharing business status across components | Zustand / Redux Toolkit / Jotai (actual selection by warehouse) |
|
|
159
|
+
| Server-side data caching | React Query / SWR |
|
|
160
|
+
| URL driver status | Route parameters / `useSearchParams` |
|
|
161
|
+
| Form State | React Hook Form / Formik |
|
|
162
|
+
|
|
163
|
+
### Core Principles
|
|
164
|
+
|
|
165
|
+
- Proximity management: try to place the state on the nearest common ancestor
|
|
166
|
+
-Single data source: Do not maintain multiple copies of the same data
|
|
167
|
+
- Derived over synchronized: computable values are calculated first at render time
|
|
168
|
+
- The server-side data is given priority to the request library management and is not manually inserted into the global store.
|
|
169
|
+
- Don’t upgrade local state to global state in advance just because it “may be used in the future”
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## API layer specification
|
|
174
|
+
|
|
175
|
+
### Design principles
|
|
176
|
+
|
|
177
|
+
- Request infrastructure is centralized in `services/`
|
|
178
|
+
-Business APIs are split by feature instead of stacking them all in one file
|
|
179
|
+
- Both request parameters and response results should have clear types
|
|
180
|
+
- Authentication, error formatting, and universal interception are handled uniformly at the request layer
|
|
181
|
+
- Do not directly scatter splicing request details on pages and components
|
|
182
|
+
|
|
183
|
+
### Example
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
// services/request.ts
|
|
187
|
+
const request = axios.create({
|
|
188
|
+
baseURL: import.meta.env.VITE_API_BASE_URL,
|
|
189
|
+
timeout: 10000,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
request.interceptors.response.use(
|
|
193
|
+
(res) => res.data,
|
|
194
|
+
(error) => {
|
|
195
|
+
if (error.response?.status === 401) {
|
|
196
|
+
redirectToLogin();
|
|
197
|
+
}
|
|
198
|
+
return Promise.reject(normalizeError(error));
|
|
199
|
+
},
|
|
200
|
+
);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
// features/user/api.ts
|
|
205
|
+
export function getUserList(
|
|
206
|
+
params: UserQueryParams,
|
|
207
|
+
): Promise<PageResult<User>> {
|
|
208
|
+
return request.get("/users", { params });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function updateUser(id: string, data: UpdateUserDTO): Promise<User> {
|
|
212
|
+
return request.put(`/users/${id}`, data);
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Error handling
|
|
219
|
+
|
|
220
|
+
### Status that must be overridden
|
|
221
|
+
|
|
222
|
+
- Loading
|
|
223
|
+
- Error
|
|
224
|
+
- Empty
|
|
225
|
+
- Data
|
|
226
|
+
|
|
227
|
+
### Recommended practices
|
|
228
|
+
|
|
229
|
+
- Use Error Boundary to wrap key functional modules to avoid local exceptions causing a full-page white screen
|
|
230
|
+
- Visible feedback must be given to the user when an asynchronous request fails
|
|
231
|
+
- Provide retry capability for important operations
|
|
232
|
+
- Don’t catch mistakes, don’t write empty `catch`
|
|
233
|
+
|
|
234
|
+
### Example (`react-error-boundary`, functional Fallback)
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
238
|
+
|
|
239
|
+
function ModuleErrorFallback({
|
|
240
|
+
resetErrorBoundary,
|
|
241
|
+
}: {
|
|
242
|
+
resetErrorBoundary: () => void;
|
|
243
|
+
}) {
|
|
244
|
+
return (
|
|
245
|
+
<div>
|
|
246
|
+
Module loading failed
|
|
247
|
+
<button type="button" onClick={resetErrorBoundary}>
|
|
248
|
+
Try again
|
|
249
|
+
</button>
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function UserDashboardSection() {
|
|
255
|
+
return (
|
|
256
|
+
<ErrorBoundary FallbackComponent={ModuleErrorFallback}>
|
|
257
|
+
<UserDashboard />
|
|
258
|
+
</ErrorBoundary>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Suspense and lazy loading
|
|
266
|
+
|
|
267
|
+
Applicable scenarios:
|
|
268
|
+
|
|
269
|
+
- Routing level page
|
|
270
|
+
- Large components such as charts, rich text editors, maps, heavy tables, etc.
|
|
271
|
+
- Modules with higher initialization costs
|
|
272
|
+
|
|
273
|
+
Example:
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
const HeavyChart = lazy(() => import("./components/HeavyChart"));
|
|
277
|
+
|
|
278
|
+
function Dashboard() {
|
|
279
|
+
return (
|
|
280
|
+
<Suspense fallback={<ChartSkeleton />}>
|
|
281
|
+
<HeavyChart data={chartData} />
|
|
282
|
+
</Suspense>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Suggestions:
|
|
288
|
+
|
|
289
|
+
- Route level priority `lazy + Suspense`
|
|
290
|
+
- `fallback` gives priority to using Skeleton or a placeholder state closer to the content instead of a pure spinner
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|