refactor: use VariantProps instead of manually defining props#731
refactor: use VariantProps instead of manually defining props#731paanSinghCoder merged 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThree component prop type definitions were refactored to derive variant types directly from their respective class-variance-authority (CVA) definitions using Possibly related issues
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/raystack/components/text-area/text-area.tsx (1)
18-25: Redundanterrorproperty declaration.The
error?: booleanon line 25 is redundant sinceVariantProps<typeof textArea>already derives theerrorvariant type from the CVA definition. This partially defeats the purpose of usingVariantProps— if the CVA variant changes, you'd still need to update the manual declaration.Consider removing the explicit
errordeclaration to fully leverageVariantProps:♻️ Suggested refactor
export interface TextAreaProps extends ComponentProps<'textarea'>, VariantProps<typeof textArea> { label?: string; required?: boolean; infoTooltip?: string; helperText?: string; - error?: boolean; disabled?: boolean; width?: string | number; value?: string; onChange?: (event: ChangeEvent<HTMLTextAreaElement>) => void; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/raystack/components/text-area/text-area.tsx` around lines 18 - 25, Remove the redundant manual error?: boolean declaration from the TextAreaProps interface so it relies on VariantProps<typeof textArea> to provide the error variant; update the TextAreaProps definition (interface TextAreaProps extends ComponentProps<'textarea'>, VariantProps<typeof textArea>) by deleting the explicit error property and ensure any usages expect the variant-provided error prop instead (references: TextAreaProps, VariantProps, textArea, error).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/raystack/components/text-area/text-area.tsx`:
- Around line 18-25: Remove the redundant manual error?: boolean declaration
from the TextAreaProps interface so it relies on VariantProps<typeof textArea>
to provide the error variant; update the TextAreaProps definition (interface
TextAreaProps extends ComponentProps<'textarea'>, VariantProps<typeof textArea>)
by deleting the explicit error property and ensure any usages expect the
variant-provided error prop instead (references: TextAreaProps, VariantProps,
textArea, error).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c77b028d-fdef-44c0-8fc1-99759e1b60ba
📒 Files selected for processing (3)
packages/raystack/components/separator/separator.tsxpackages/raystack/components/tabs/tabs.tsxpackages/raystack/components/text-area/text-area.tsx
Description
refactor: use VariantProps from cva instead of manually defining.
Type of Change
How Has This Been Tested?
[Describe the tests that you ran to verify your changes]
Checklist:
Screenshots (if appropriate):
[Add screenshots here]
Related Issues
[Link any related issues here using #issue-number]