fix(project-detect): match packageKeys on boundaries, not substrings (preact→react)#2181
Conversation
Framework detection matched a dependency against a framework's packageKeys with unbounded substring containment (dep.includes(key)), so any dependency whose name merely contained a key was misclassified: `preact` and even `reactive` were both detected as `react`. Match only when the dependency equals the key, or the key is a prefix immediately followed by a delimiter (/ . _ -). This still matches every real case (react-dom, @remix-run/node, spring-boot-starter, org.springframework.boot, github.com/labstack/echo/v4, phoenix_live_view) while excluding preact/reactive (and incidentally nextra). Adds regression tests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes framework dependency detection by replacing naive substring matching with boundary-aware prefix matching. The logic now treats a dependency key as matching only when it equals the target (case-insensitive) or when it is a prefix immediately followed by a delimiter, preventing false positives like ChangesFramework Detection Boundary Matching
🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ffaan-m#2181) Framework detection matched a dependency against a framework's packageKeys with unbounded substring containment (dep.includes(key)), so any dependency whose name merely contained a key was misclassified: `preact` and even `reactive` were both detected as `react`. Match only when the dependency equals the key, or the key is a prefix immediately followed by a delimiter (/ . _ -). This still matches every real case (react-dom, @remix-run/node, spring-boot-starter, org.springframework.boot, github.com/labstack/echo/v4, phoenix_live_view) while excluding preact/reactive (and incidentally nextra). Adds regression tests. Co-authored-by: bymle <229636660+bymle@users.noreply.github.com>
Problem
Framework detection misclassifies dependencies whose name merely contains a framework key.
project-detect.jsreportspreact— and evenreactive— asreact:Other collisions:
svelte-check-only →svelte,nextra→nextjs.Root cause
String.includesis unbounded substring matching with no name boundary.Fix
Match only when the dependency equals the key, or the key is a prefix immediately followed by a delimiter (
/._-):This still matches every real case —
react-dom,@remix-run/node,spring-boot-starter,org.springframework.boot,github.com/labstack/echo/v4,phoenix_live_view— while excludingpreact/reactive(and incidentally fixingnextra).I kept all four delimiters (
/ . _ -) so the dotted/scoped/underscored ecosystem keys (Spring, Go module paths, Elixir) keep working — happy to tune the delimiter set if you'd prefer something narrower.Tests
Adds regression tests to
tests/lib/project-detect.test.js:preact/reactiveno longer map toreact, andreact-domalone still does. Full file: 33 passed, 0 failed (the 2 new negative cases fail on currentmain).Summary by cubic
Fix framework detection by matching
packageKeyson name boundaries instead of substrings. This stops false positives likepreact/reactive→reactwhile keepingreact-domand@remix-run/nodeworking./ . _ -).Written for commit b517a8a. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests