-
-
Notifications
You must be signed in to change notification settings - Fork 245
fix(ui): prevent compare with non-existing package #1207
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
fix(ui): prevent compare with non-existing package #1207
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThe Enter key handler in the package selector component was changed to trim the input and verify that the trimmed value matches an item in the current filtered results or corresponds to the No Dependency option before calling addPackage. Enter now only adds when the trimmed input is non-empty and a matching item or NO_DEPENDENCY_ID exists. No exported or public signatures were changed. Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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: 1
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: 1
| const emitted = component.emitted('update:modelValue') | ||
| expect(emitted).toBeTruthy() | ||
| expect(emitted![0]![0]).toEqual(['my-package']) | ||
| expect(emitted![0]![0]).toEqual(['lodash']) | ||
| }) |
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.
Add an explicit guard before indexing emitted arrays.
Line 146–149 and Line 162–165 index into emitted without a concrete length check. This breaks the codebase’s strict type-safety guideline for array indexing.
Proposed fix
- const emitted = component.emitted('update:modelValue')
- expect(emitted).toBeTruthy()
- expect(emitted![0]![0]).toEqual(['lodash'])
+ const emitted = component.emitted('update:modelValue') ?? []
+ expect(emitted.length).toBe(1)
+ expect(emitted[0]?.[0]).toEqual(['lodash'])- const emitted = component.emitted('update:modelValue')
- expect(emitted).toBeTruthy()
- expect(emitted![0]![0]).toEqual(['__no_dependency__'])
+ const emitted = component.emitted('update:modelValue') ?? []
+ expect(emitted.length).toBe(1)
+ expect(emitted[0]?.[0]).toEqual(['__no_dependency__'])As per coding guidelines, "Ensure you write strictly type-safe code, for example by ensuring you always check when accessing an array value by index".
Also applies to: 162-165
closes #1198