Skip to content

feat: exclude deprecated and prerelease versions from completion + add config#27

Open
nitodeco wants to merge 3 commits intonpmx-dev:mainfrom
nitodeco:feat/filter-versions
Open

feat: exclude deprecated and prerelease versions from completion + add config#27
nitodeco wants to merge 3 commits intonpmx-dev:mainfrom
nitodeco:feat/filter-versions

Conversation

@nitodeco
Copy link
Collaborator

@nitodeco nitodeco commented Feb 5, 2026

Resolves #25

Config option:
image

Default disabled:
image

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

@nitodeco nitodeco force-pushed the feat/filter-versions branch from 280d977 to 8a37d2b Compare February 5, 2026 01:36
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Updates add a new boolean configuration npmx.completion.excludePrerelease (default: true) to exclude prerelease versions from completion suggestions. README table formatting was adjusted to include the new option. A new exported RegExp PRERELEASE_PATTERN was added to identify prerelease identifiers (alpha, beta, rc, canary). The version completion provider now skips entries where meta.deprecated is set and, when npmx.completion.excludePrerelease is true, skips versions matching PRERELEASE_PATTERN. No public APIs were removed or altered.

Possibly related PRs

  • PR 18 (npmx-dev/vscode-npmx): Modifies src/providers/completion-item/version.ts to restructure iteration and add provenance/tag-based filtering of version completion items.
  • PR 29 (npmx-dev/vscode-npmx): Rewrites version parsing/formatting and semver handling in src/providers/completion-item/version.ts, affecting version candidate selection.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description references issue #25 and includes screenshots demonstrating the new configuration option for excluding prerelease versions.
Linked Issues check ✅ Passed The pull request addresses issue #25 by excluding deprecated and prerelease versions from completion suggestions, implementing the core requirement to filter problematic releases.
Out of Scope Changes check ✅ Passed All changes directly support the objective of filtering versions from completion suggestions; no out-of-scope modifications were introduced.

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

@9romise
Copy link
Member

9romise commented Feb 5, 2026

Wow! Excellent idea.

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

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": {
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link

Choose a reason for hiding this comment

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

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

Ok! Then lets do this!

@nitodeco
Copy link
Collaborator Author

nitodeco commented Feb 5, 2026

Exclude prerelease versions alpha beta, rc  canary) from completion suggestions

@nitodeco nitodeco force-pushed the feat/filter-versions branch from d82397f to b89f592 Compare February 5, 2026 11:18
Copy link

@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 42 to +49
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
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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

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.

Filter the versions in the completion list

3 participants