Skip to content

Comments

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

Merged
9romise merged 5 commits intonpmx-dev:mainfrom
nitodeco:feat/filter-versions
Feb 5, 2026
Merged

feat: exclude deprecated and prerelease versions from completion + add config#27
9romise merged 5 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
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Adds a new boolean configuration npmx.completion.excludePrerelease (default true) to exclude prerelease versions from completion suggestions and updates README table layout to include the option. Introduces an exported PRERELEASE_PATTERN RegExp (/-.+/) in src/constants.ts. 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

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is related to the changeset and references the linked issue #25, demonstrating clear connection between the description and code changes.
Linked Issues check ✅ Passed The pull request successfully addresses issue #25 by excluding deprecated and prerelease versions from completion suggestions, implementing both filtering logic and user-configurable settings.
Out of Scope Changes check ✅ Passed All code changes directly support the objectives of filtering versions in completion lists; README, package.json, constants, and version provider modifications are all in-scope and necessary for the feature.

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

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

@nitodeco nitodeco requested review from 9romise and RYGRIT February 5, 2026 13:38
src/constants.ts Outdated
export const PNPM_WORKSPACE_PATTERN = `**/${PNPM_WORKSPACE_BASENAME}`

export const VERSION_TRIGGER_CHARACTERS = [':', '^', '~', '.', ...Array.from({ length: 10 }).map((_, i) => `${i}`)]
export const PRERELEASE_PATTERN = /-(?:alpha|beta|rc|canary)/i
Copy link
Contributor

Choose a reason for hiding this comment

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

The PRERELEASE_PATTERN seems a bit too restrictive.

Using a whitelist (alpha|beta|rc|canary) will miss many common prerelease tags, such as next (e.g., vue@next), dev, or nightly.

Suggestion: Since SemVer defines a prerelease as anything following a hyphen, a generic regex would be safer:

// Matches any version containing a hyphen
export const PRERELEASE_PATTERN = /-.+/;

(Or use semver.prerelease() if the package is available.)

@9romise 9romise merged commit 4dad172 into npmx-dev:main Feb 5, 2026
6 checks passed
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