Skip to content

Conversation

@iiio2
Copy link
Contributor

@iiio2 iiio2 commented Feb 8, 2026

resolves #1198

not-found

@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 1:54pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 8, 2026 1:54pm
npmx-lunaria Ignored Ignored Feb 8, 2026 1:54pm

Request Review

@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

❌ Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/components/Compare/PackageSelector.vue 89.28% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

The PackageSelector component now validates package existence before adding on Enter: if the typed name exactly matches a dropdown item it is added immediately, otherwise an async check (checkPackageExists) runs. New UI state properties track verification progress (isCheckingPackage) and errors (packageError); the input is disabled and shows a spinner while checking, and errors render an alert. Tests were updated to mock the existence check, use flushPromises for async flows, and verify that non-existent packages are not added and that input clearing and no-dependency behavior remain correct.

Possibly related PRs

Suggested labels

front, a11y

Suggested reviewers

  • danielroe
  • alexdln
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Changes to LicenseDisplay.vue styling and the unocss-checker workflow update appear unrelated to the core objective of preventing non-existent package additions. Reconsider whether LicenseDisplay.vue styling changes and CSS checker workflow modifications are necessary for this PR, or separate them into a distinct pull request focused on CSS linting improvements.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description references issue #1198 and includes a screenshot demonstrating the problem of adding non-existent packages, directly relating to the changeset.
Linked Issues check ✅ Passed The PR implements validation to prevent adding non-existent packages [#1198] through async checks in PackageSelector.vue, comprehensive test coverage, and supporting infrastructure changes.

✏️ 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

Comment on lines +86 to 116
async function handleKeydown(e: KeyboardEvent) {
if (e.key !== 'Enter' || !inputValue.value.trim() || isCheckingPackage.value) return
e.preventDefault()

const name = inputValue.value.trim()
if (packages.value.length >= maxPackages.value) return
if (packages.value.includes(name)) return

// If it matches a dropdown result, add immediately (already confirmed to exist)
const exactMatch = filteredResults.value.find(r => r.name === name)
if (exactMatch) {
addPackage(exactMatch.name)
return
}

// Otherwise, verify it exists on npm
isCheckingPackage.value = true
packageError.value = ''
try {
const exists = await checkPackageExists(name)
if (name !== inputValue.value.trim()) return // stale guard
if (exists) {
addPackage(name)
} else {
packageError.value = `Package "${name}" was not found on npm.`
}
} catch {
packageError.value = 'Could not verify package. Please try again.'
} finally {
isCheckingPackage.value = false
}
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

Avoid misleading “not found” on network failures.
checkPackageExists returns false for any fetch error, so the “not found” message will also show on registry/network issues and the catch branch will effectively never run. Consider returning a richer status from the util, or make the message neutral.

💡 Possible message adjustment
-      packageError.value = `Package "${name}" was not found on npm.`
+      packageError.value = `Package "${name}" was not found or could not be verified.`
📝 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.

Suggested change
async function handleKeydown(e: KeyboardEvent) {
if (e.key !== 'Enter' || !inputValue.value.trim() || isCheckingPackage.value) return
e.preventDefault()
const name = inputValue.value.trim()
if (packages.value.length >= maxPackages.value) return
if (packages.value.includes(name)) return
// If it matches a dropdown result, add immediately (already confirmed to exist)
const exactMatch = filteredResults.value.find(r => r.name === name)
if (exactMatch) {
addPackage(exactMatch.name)
return
}
// Otherwise, verify it exists on npm
isCheckingPackage.value = true
packageError.value = ''
try {
const exists = await checkPackageExists(name)
if (name !== inputValue.value.trim()) return // stale guard
if (exists) {
addPackage(name)
} else {
packageError.value = `Package "${name}" was not found on npm.`
}
} catch {
packageError.value = 'Could not verify package. Please try again.'
} finally {
isCheckingPackage.value = false
}
async function handleKeydown(e: KeyboardEvent) {
if (e.key !== 'Enter' || !inputValue.value.trim() || isCheckingPackage.value) return
e.preventDefault()
const name = inputValue.value.trim()
if (packages.value.length >= maxPackages.value) return
if (packages.value.includes(name)) return
// If it matches a dropdown result, add immediately (already confirmed to exist)
const exactMatch = filteredResults.value.find(r => r.name === name)
if (exactMatch) {
addPackage(exactMatch.name)
return
}
// Otherwise, verify it exists on npm
isCheckingPackage.value = true
packageError.value = ''
try {
const exists = await checkPackageExists(name)
if (name !== inputValue.value.trim()) return // stale guard
if (exists) {
addPackage(name)
} else {
packageError.value = `Package "${name}" was not found or could not be verified.`
}
} catch {
packageError.value = 'Could not verify package. Please try again.'
} finally {
isCheckingPackage.value = false
}
}

@danielroe
Copy link
Member

looks like this was just a second behind #1207

is there anything in this pr that you'd recommend keeping? if so, would you resolve conflicts? 🙏

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 +62 to +65
const dir = glob(argvFiles.length > 0 ? argvFiles : '**/*.vue', {
withFileTypes: true,
cwd: APP_DIRECTORY,
})
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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Examine the full unocss-checker.ts to understand argument handling
echo "=== Full unocss-checker.ts content ==="
cat scripts/unocss-checker.ts

echo -e "\n=== Checking for APP_DIRECTORY definition ==="
rg "APP_DIRECTORY" scripts/ --type ts -B2 -A2

Repository: npmx-dev/npmx.dev

Length of output: 3519


🏁 Script executed:

#!/bin/bash
# Check lint-staged configuration and how the script is invoked
echo "=== lint-staged config in package.json ==="
cat package.json | grep -A10 "lint-staged"

echo -e "\n=== Scripts section in package.json ==="
cat package.json | grep -A20 '"scripts"'

echo -e "\n=== Check how lint:css is defined ==="
grep -r "lint:css" package.json

Repository: npmx-dev/npmx.dev

Length of output: 1916


Fix the file path handling in unocss-checker.ts when invoked via lint-staged.

When lint-staged runs pnpm lint:css, it passes staged file paths as arguments relative to the repository root (e.g., app/components/Foo.vue). However, the glob is executed with cwd: APP_DIRECTORY (an absolute path pointing to the app directory), causing a mismatch. The script attempts to locate files at paths like <APP_DIRECTORY>/app/components/Foo.vue instead of <APP_DIRECTORY>/components/Foo.vue, which will fail.

Either strip the app/ prefix from paths passed by lint-staged, or adjust the cwd and path handling logic.

@iiio2
Copy link
Contributor Author

iiio2 commented Feb 8, 2026

@danielroe , pls see this. This is fresh pr #1218

@iiio2 iiio2 closed this 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

4 participants