Skip to content

feat(completion): support 'npm:'-prefixed versions#29

Merged
9romise merged 8 commits intomainfrom
parse-version
Feb 5, 2026
Merged

feat(completion): support 'npm:'-prefixed versions#29
9romise merged 8 commits intomainfrom
parse-version

Conversation

@9romise
Copy link
Member

@9romise 9romise commented Feb 5, 2026

  1. unify the version parsing and formatting
  2. support 'npm: ' -prefixed version completion

Close #15

# Conflicts:
#	src/providers/diagnostics/rules/deprecation.ts
#	src/providers/hover/npmx.ts
@9romise 9romise marked this pull request as draft February 5, 2026 04:01
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

This PR replaces legacy version-prefix helpers with a structured parsing/formatting flow: parseVersion and formatVersion were added to src/utils/package.ts (new ParsedVersion and VersionProtocol types). Providers for completion, hover and diagnostics were updated to use parseVersion and semver for lookups and URL construction, with early returns on parse failure. Tests for parseVersion and encodePackageName were added. src/constants.ts adjusted VERSION_TRIGGER_CHARACTERS to include : first. playground/package.json added a nuxt dependency using the npm: protocol.

Possibly related PRs

  • npmx-dev/vscode-npmx PR 18 — touches provider logic and version/metadata lookup patterns, aligning with the migration to structured version parsing.
  • npmx-dev/vscode-npmx PR 22 — modifies the hover provider and link/markdown construction, overlapping hover-related changes.
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning All changes are focused on version parsing refactoring and npm: prefix support; playground/package.json change appears unrelated to the core objectives. Remove the playground/package.json change adding nuxt dependency, as it is unrelated to version parsing refactoring or npm: prefix completion support.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is directly related to the changeset, describing the unification of version parsing/formatting and npm: prefix support.
Linked Issues check ✅ Passed The pull request implements version parsing validation and npm: protocol support, which aligns with closing issue #15 on version validation.

✏️ 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
  • Commit unit tests in branch parse-version

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/providers/completion-item/version.ts (1)

35-50: ⚠️ Potential issue | 🟠 Major

Preserve the npm: protocol in completion insert text.
parseVersion now carries protocol, but the completion item only uses prefix, so a dependency like npm:^1.0.0 would be replaced with ^x.y.z, changing its meaning. Please reapply the protocol when building the insert text.

🛠️ Suggested fix
-    const { prefix } = parsed
+    const { prefix, protocol } = parsed
+    const protocolPrefix = protocol ? `${protocol}:` : ''

     const items: CompletionItem[] = []

     for (const version in pkg.versionsMeta) {
       const meta = pkg.versionsMeta[version]
@@
-      const text = `${prefix}${version}`
+      const text = `${protocolPrefix}${prefix}${version}`
       const item = new CompletionItem(text, CompletionItemKind.Value)

@9romise 9romise changed the title feat: unify version parsing logic feat(completion): support 'npm:'-prefixed versions Feb 5, 2026
@9romise 9romise marked this pull request as ready for review February 5, 2026 06:20
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

🧹 Nitpick comments (1)
tests/package.test.ts (1)

14-66: Consider adding an invalid/empty version edge case.

A test for inputs like npm: or npm:^ would lock in the expected null/guard behaviour for malformed versions.

@9romise 9romise merged commit da17a10 into main Feb 5, 2026
6 checks passed
@9romise 9romise deleted the parse-version branch February 5, 2026 09:27
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.

Validate the version

1 participant