feat: exclude deprecated and prerelease versions from completion + add config#27
feat: exclude deprecated and prerelease versions from completion + add config#27nitodeco wants to merge 3 commits intonpmx-dev:mainfrom
Conversation
280d977 to
8a37d2b
Compare
📝 WalkthroughWalkthroughUpdates add a new boolean configuration Possibly related PRs
🚥 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 |
|
Wow! Excellent idea.
I think filtering out deprecated versions directly is perfectly fine. If someone requests to see them, we can always provide an option for that time — but I doubt anyone would intentionally select a deprecated version when updating, right? 🤔 |
package.json
Outdated
| "default": "provenance-only", | ||
| "description": "Version completion behavior" | ||
| }, | ||
| "npmx.completion.showPrerelease": { |
There was a problem hiding this comment.
Could we place this option under the version level? For example: npmx.completion.version.prelease.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
I appreciate the forward-thinking!
However, I feel that exposing 3 separate boolean flags just for version completion might be a bit too verbose/complex for the user.
I’d prefer a simpler Enum + Boolean pattern:
npmx.completion.version: Enum (Controls the source/strategy, e.g., "all" vs "provenance")
npmx.completion.excludePrerelease: Boolean (Independent filter)
This keeps the config clean while still covering the necessary logic. Since we're in preview, keeping the API surface small seems like a safer bet. WDYT?
There was a problem hiding this comment.
npmx.completion.version: Enum (Controls the source/strategy, e.g., "all" vs "provenance")
npmx.completion.excludePrerelease: Boolean (Independent filter)
I like this, not too verbose and easy to expand
d82397f to
b89f592
Compare
| for (const semver in pkg.versionsMeta) { | ||
| const meta = pkg.versionsMeta[semver] | ||
|
|
||
| if (meta.deprecated != null) | ||
| continue | ||
|
|
||
| if (config.completion.excludePrerelease && PRERELEASE_PATTERN.test(version)) | ||
| continue |
There was a problem hiding this comment.
Use the candidate semver when filtering prereleases.
Line 48 tests the installed version, not the candidate semver. This can wrongly skip or include suggestions.
✅ Suggested fix
- if (config.completion.excludePrerelease && PRERELEASE_PATTERN.test(version))
+ if (config.completion.excludePrerelease && PRERELEASE_PATTERN.test(semver))
continue
Resolves #25
Config option:

Default disabled:

Excludes deprecated versions completely. @9romise Do you think we need an option to show those as well?