fix: pass name/version separately in comparison grid#1098
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe ComparisonGrid component's data structure has been refactored to replace a single 🚥 Pre-merge checks | ❌ 1❌ Failed checks (1 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/nuxt/components/compare/ComparisonGrid.spec.ts (1)
5-10:cols()helper will misbehave with scoped package names.
header.split('@')on a scoped package like@vue/compiler-sfc@3.0.0yields['', 'vue/compiler-sfc', '3.0.0'], sonamebecomes''andversionbecomes'vue/compiler-sfc'. No current test exercises this path, but it's a latent trap if scoped-package tests are added later.🔧 Suggested safer split
function cols(...headers: string[]) { return headers.map(header => { - const [name, version] = header.split('@') - return { name: name!, version } + const atIndex = header.lastIndexOf('@') + if (atIndex > 0) { + return { name: header.slice(0, atIndex), version: header.slice(atIndex + 1) } + } + return { name: header, version: undefined } }) }
| :key="col.header" | ||
| class="comparison-cell comparison-cell-header" | ||
| > | ||
| <div v-for="col in columns" :key="col.name" class="comparison-cell comparison-cell-header"> |
There was a problem hiding this comment.
v-for key col.name may not be unique when comparing different versions of the same package.
If a user compares e.g. lodash@4.17.20 vs lodash@4.17.21, both columns would have col.name === 'lodash', causing a Vue key collision warning and potential rendering issues. Consider using a composite key that includes the version.
🔧 Suggested fix
- <div v-for="col in columns" :key="col.name" class="comparison-cell comparison-cell-header">
+ <div v-for="col in columns" :key="col.version ? `${col.name}@${col.version}` : col.name" class="comparison-cell comparison-cell-header">📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <div v-for="col in columns" :key="col.name" class="comparison-cell comparison-cell-header"> | |
| <div v-for="col in columns" :key="col.version ? `${col.name}@${col.version}` : col.name" class="comparison-cell comparison-cell-header"> |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
No description provided.