Skip to content

Conversation

@MatteoGabriele
Copy link
Contributor

closes #1198

@vercel
Copy link

vercel bot commented Feb 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 8, 2026 0:36am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 8, 2026 0:36am
npmx-lunaria Ignored Ignored Feb 8, 2026 0:36am

Request Review

@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

The 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

  • danielroe
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description references issue #1198, which relates directly to the changeset preventing non-existing packages from being added to the comparison table.
Linked Issues check ✅ Passed The code changes implement the required functionality by adding validation to check for matching items in filtered results before allowing package additions, directly addressing the issue requirement.
Out of Scope Changes check ✅ Passed All changes are scoped to the PackageSelector component and its tests, directly implementing the validation logic required to prevent adding non-existing packages.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Comment on lines 146 to +149
const emitted = component.emitted('update:modelValue')
expect(emitted).toBeTruthy()
expect(emitted![0]![0]).toEqual(['my-package'])
expect(emitted![0]![0]).toEqual(['lodash'])
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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

@danielroe danielroe added this pull request to the merge queue Feb 8, 2026
Merged via the queue into npmx-dev:main with commit 50ed3fb Feb 8, 2026
17 checks passed
iiio2 pushed a commit to iiio2/npmx.dev that referenced this pull request Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent adding non-existing package

2 participants