vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.75k stars 1.15k forks source link

feat(dx): warn when `addRoute` cannot find the parent #2157

Closed skirtles-code closed 4 months ago

skirtles-code commented 4 months ago

This adds a warning when calling router.addRoute('foo', { ... }) if the parent route isn't found.

Without this warning, it can be difficult to tell why addRoute isn't working correctly. With an absolute path, beginning with /, the addition seems to succeed, but the new route won't be a child of the intended parent. With a relative path, it'll fail to add the new route, but with a confusing error about the path being invalid.

I've also added a test for the similar warning in removeRoute, though the warning itself already existed.

netlify[bot] commented 4 months ago

Deploy Preview for vue-router canceled.

Name Link
Latest commit 364cd0490b9c7c0ff552951c96b62f34289305ed
Latest deploy log https://app.netlify.com/sites/vue-router/deploys/65e27d8ab04dbe0008af77a3
codecov-commenter commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.90%. Comparing base (13303bd) to head (364cd04).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2157 +/- ## ======================================= Coverage 90.90% 90.90% ======================================= Files 24 24 Lines 1121 1121 Branches 347 347 ======================================= Hits 1019 1019 Misses 63 63 Partials 39 39 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.