redwood: [RFC]: Warn on duplicate routes

Summary

A tutorial user just ran into this issue, and I’ve seen it myself: a route is listed more than once in Routes.tsx and the first one always matches. Which is the expected behavior, but it can be scary if you overlook the duplication (which several of us did when trying to debug this issue).

Maybe it would be possible to scan through the Routes file and generate a warning to the console if a duplicate is found? Just a nice little DX addition.

Motivation

Being confused as hell as to why I route wasn’t including the <Set> layout wrapped around it: a duplicate route was outside the <Set> and matching first.

Detailed proposal

Write code to make this work.

Are you interested in working on this?

  • I’m interested in working on this

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Hi, just a newbie here but thought I’d try and contribute at least a tiny useful thing. I dug around a bit to see what other web frameworks do with duplicate route console warnings. The only example I could find was from vue-router, which is nice though could perhaps be improved:

vue-router.esm.js:16 [vue-router] Duplicate named routes definition: { name: "some_url", path: "/some_url" }

@pantheredeye @cannikin thank you for your thoughtful help yesterday when I ran into this error as a tutorial user, and for thinking of other users who may run into similar bugs.

Just for the record I updated the test-project to have a ContactUs page rather than just Contact, so the names no longer conflict with the scaffolded contacts.