-
Notifications
You must be signed in to change notification settings - Fork 330
fix(button-group): [button-group] update size prop type and add validator #3038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis PR updates the type declaration for the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
examples/sites/demos/apis/button-group.jsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-vue". (The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. packages/vue/src/button-group/src/index.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-vue". (The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThis pull request updates the Changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
examples/sites/demos/apis/button-group.js (2)
69-69: Type definition improved to reflect valid options.The change from a generic string type to a specific union type (
'medium' | 'small' | 'mini') enhances the API documentation by explicitly listing the valid values for thesizeproperty. This improves developer experience by making it clear what options are available.Consider including the empty string (
'') in the type definition to fully match the validator implementation in the component, which accepts an empty string as a valid value:- type: "'medium' | 'small' | 'mini'", + type: "'medium' | 'small' | 'mini' | ''",
93-93: Inconsistent type notation for v-model.While unrelated to the current changes, there's an inconsistency in the type notation. Here you're using
'Number / String'format, but elsewhere TypeScript-style union types are used.Consider standardizing the type notation to match TypeScript conventions:
- type: 'Number / String', + type: 'number | string',
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
examples/sites/demos/apis/button-group.js(1 hunks)packages/vue/src/button-group/src/index.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (2)
packages/vue/src/button-group/src/index.ts (2)
19-23: Well-implemented validator for size property.Good implementation of the validator function to restrict the
sizeproperty to only valid values. The addition of a default value and proper validation enhances the component's robustness.The validator correctly includes both the documented values ('medium', 'small', 'mini') and the empty string ('') as a valid value, which likely represents a default or auto size. This ensures backward compatibility with existing code.
19-23:❓ Verification inconclusive
Verify that existing usages comply with the new validator.
Since you've added a validator that restricts the
sizeproperty to specific values, it's important to ensure that all existing usages of the component comply with these restrictions.
🏁 Script executed:
#!/bin/bash # Find all usages of the button-group component with a size prop # This might help identify if there are any instances using invalid size values echo "Searching for button-group usages with size prop..." # Look for Vue template usages rg -i "<tiny-button-group[^>]*size=['\"][^'\"]*['\"]" --type html --type vue # Look for JSX usages rg -i "TinyButtonGroup[^>]*size=['\"][^'\"]*['\"]" --type js --type jsx --type tsx # Look for programmatic usages rg -i "buttonGroup[^\.]*\.size\s*=" --type js --type tsLength of output: 402
Verify that all usages of the
sizeproperty conform to the new restrictions.The updated code limits the
sizeprop to['medium', 'small', 'mini', '']. However, our automated search scripts returned file type errors (unrecognized file types:vue,jsx), meaning the search results aren’t reliable. Please manually verify that every instance of the button-group (or TinyButtonGroup) component is using one of the permitted size values or adjust the search parameters to ensure proper coverage.
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #3022
What is the new behavior?
validate size property
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit