docs: add component-migration.md cursor rule#946
Conversation
📖 Storybook Preview |
2dd5a84 to
cbd95ff
Compare
📖 Storybook Preview |
📖 Storybook Preview |
25957ad to
7d17b72
Compare
📖 Storybook Preview |
75dd567 to
26fd0a6
Compare
26fd0a6 to
03c1bb5
Compare
|
|
||
| Guide for migrating components from MetaMask Extension and Mobile component-library folders into the design system monorepo. | ||
|
|
||
| ## Purpose |
There was a problem hiding this comment.
This cursor rule defines the PRIMARY workflow for migrating components from Extension and Mobile component-library folders. It addresses the most common development task: consolidating existing consumer components into the monorepo while applying ADR-0003/0004 patterns.
|
|
||
| - **Conservative:** Accept partial alignment, document gaps for Phase 2 | ||
| - **Unified:** Consolidate props immediately with `@deprecated` transition | ||
|
|
There was a problem hiding this comment.
Two migration strategies accommodate different scenarios: Conservative approach defers breaking changes for components with high usage (accepting partial alignment initially), while Unified approach consolidates props immediately for low-usage components (using @deprecated for graceful migration).
| - Brand new components from scratch → @.cursor/rules/component-creation.md | ||
|
|
||
| ## Migration Strategy Decision | ||
|
|
There was a problem hiding this comment.
Decision tree helps AI agents choose the appropriate strategy based on component usage level and whether consumers can be updated in the same PR. This prevents unnecessary breaking changes while allowing consolidation when feasible.
📖 Storybook Preview |
| - Which props are platform-specific? (onClick/onPress, className/twClassName) | ||
| - Are there naming conflicts? (disabled vs isDisabled) | ||
| - What's the unified API that serves both platforms? | ||
|
|
There was a problem hiding this comment.
Prop alignment principles explicitly permit partial alignment. Shared types are created for any matching props, even minimal overlap, while accepting platform-specific differences. This pragmatic approach balances consistency with platform idioms.
| - Event handlers from base types (onClick/onPress) | ||
|
|
||
| ### Phase 2.5: Implementation Patterns | ||
|
|
There was a problem hiding this comment.
Conservative approach pattern provides concrete examples of documenting alignment gaps. GitHub issues track Phase 2 work for future major version upgrades, preventing migration blockers while maintaining clear technical debt visibility.
| Labels: phase-2, alignment, breaking-change | ||
| ``` | ||
|
|
||
| #### Unified Approach Pattern |
There was a problem hiding this comment.
Unified approach pattern demonstrates complete migration workflow with deprecation strategy. JSDoc @deprecated tags provide IDE warnings, effectiveDisabled pattern maintains backwards compatibility, and migration map guides consumers through prop changes.
| 3. Tests (props render, variants apply, interactive states work) | ||
| 4. Figma Code Connect (if applicable) - see @.cursor/rules/figma-integration.md | ||
|
|
||
| **React:** README.mdx with Canvas blocks |
There was a problem hiding this comment.
Anti-patterns section targets common AI agent mistakes observed during component migrations. Each example contrasts wrong approach (direct copy, hardcoded values, platform props in shared) with correct monorepo patterns to prevent repeated errors.
|
|
||
| // ✅ Correct - className only in platform package | ||
| export type ButtonPropsShared = { | ||
| variant?: ButtonVariant; |
There was a problem hiding this comment.
Comprehensive verification checklist ensures AI agents complete all migration phases. Covers audit, API design, implementation, documentation, and build verification with concrete checklist items for both conservative and unified approaches.
|
|
||
| - [ ] Storybook stories, README, tests for both platforms | ||
| - [ ] Figma Code Connect (if applicable) | ||
| - [ ] Migration documented in centralized MIGRATION.md (preferred) |
There was a problem hiding this comment.
References section provides structured navigation to all related documentation. Links to required reading (architecture, creation, styling, documentation rules), migration strategy docs, source repositories, ADRs, and MetaMask contributor standards guide agents to comprehensive context.
| - @.cursor/rules/component-architecture.md | ||
| - @.cursor/rules/component-creation.md | ||
| - @.cursor/rules/component-enum-union-migration.md | ||
| - @.cursor/rules/component-migration.md |
There was a problem hiding this comment.
CLAUDE.md update adds component-migration.md to the cursor rules list, ensuring AI agents automatically load this PRIMARY workflow for bringing Extension and Mobile components into the monorepo. Positioned after component-enum-union-migration.md to maintain logical ordering.
📖 Storybook Preview |
## Description - migrate MainActionButton from MetaMask Mobile component-library temp components into @metamask/design-system-react-native - add component source, types, constants, styles, stories, tests, and README under packages/design-system-react-native/src/components/MainActionButton - export MainActionButton from RN components barrel ## Related issue - https://consensyssoftware.atlassian.net/browse/DSYS-296 ## Screenshots ### Mobile https://github.com/user-attachments/assets/7f8cc1d5-f829-4308-8415-c3a2f622ca8c ### MMDS https://github.com/user-attachments/assets/bcc0e97c-9ffa-4552-83a6-aea3ae625461 ## Notes - migration followed the component migration rule from PR #946 and existing component creation/documentation/styling rules in this repo <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: primarily adds a new UI component and Storybook/test coverage with minimal impact on existing runtime logic aside from a new public export. > > **Overview** > Introduces `MainActionButton` into `@metamask/design-system-react-native`, implementing the component (press/disabled behavior, Tailwind-based styling, icon+single-line label) along with `MainActionButtonProps`, README documentation, Storybook stories, and a test suite. > > Updates the RN components barrel export and Storybook requires list to surface the new stories, and makes a tiny cleanup in `TabEmptyState` Storybook story (removes an eslint-disable comment). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a19f71a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Description
Adds
component-migration.mdcursor rule providing the PRIORITY workflow for bringing components from MetaMask extension or mobile codebases into the design system monorepo. This is the primary workflow AI agents should use for component work, as most components originate from consumer applications rather than being created from scratch.Complete migration workflow documented:
create-component:reactandcreate-component:react-nativescripts@metamask/design-system-shared(ADR-0004)Critical patterns:
.types.tsimports only,index.tsexports only@metamask/design-system-sharedpackage (ADR-0004)as constinstead of TypeScript enums (ADR-0003)component-creation.mdfor technical scaffolding detailsWhen to use this workflow:
✅ Bringing component from extension or mobile (PRIORITY)
✅ Component exists in consumer app but not in design system
✅ User references extension or mobile component
NOT for:
❌ Brand new components with no prior implementation (use
component-creation.md)❌ Internal monorepo refactoring (use
component-enum-union-migration.md)Why this matters:
Most design system components originate from MetaMask extension or mobile applications. This workflow ensures proper migration that maintains functionality while adopting design system patterns. The BadgeCount migration (PR #942) validated these patterns, particularly the importance of correct export structure for test coverage.
Relationship to other rules:
component-architecture.md(foundational patterns)component-creation.md(references for technical scaffolding steps)component-enum-union-migration.md(internal refactoring only)References:
create-component:reactandcreate-component:react-nativeRelated issues
Fixes: https://consensyssoftware.atlassian.net/browse/DSYS-343
Manual testing steps
.cursor/rules/component-migration.mdcomponent-creation.mdfor scaffolding detailsScreenshots/Recordings
N/A - Documentation only
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Low risk documentation-only change that adds guidance for future migrations without altering runtime code or build behavior.
Overview
Adds a new Cursor rule,
.cursor/rules/component-migration.md, documenting the primary workflow for migrating components from MetaMask Extension/Mobile into the monorepo, including audit steps, shared-type layering guidance, conservative vs unified alignment strategies, and verification checklists.Updates
CLAUDE.mdto reference this new rule in the list of AI-agent conventions.Written by Cursor Bugbot for commit d8b8736. This will update automatically on new commits. Configure here.