eslint-plugin-remix-react-routes icon indicating copy to clipboard operation
eslint-plugin-remix-react-routes copied to clipboard

Consider `<Link relative="path">`

Open jenseng opened this issue 2 years ago • 0 comments

Currently the rules evaluate paths in relation to the route containing the element, as is the case with <Link> by default at runtime; i.e. consider a route hierarchy like so:

  • /accounts
    • /$accountId
      • /projects
        • /$projectId

If the /projects route has a <Link to="..">, it will always point to /accounts/$accountId, even if our current path is /accounts/$accountId/projects/$projectId

<Link relative="path"> makes it relative to the current path. So in the example above, that same link with relative="path" would point to /accounts/$accountId/projects when the current path is /accounts/$accountId/projects/$projectId.

We should make the rule aware of that; we can't know what the current path will actually be, so perhaps the rule could ignore such elements by default, but also consider optionally detecting/reporting them based on an option.

jenseng avatar Dec 07 '22 16:12 jenseng