eslint-plugin-ember icon indicating copy to clipboard operation
eslint-plugin-ember copied to clipboard

should any form of transition be an error if occurring from the application route

Open NullVoxPopuli opened this issue 2 years ago • 2 comments

Originally reported here: https://github.com/emberjs/rfcs/issues/759

I ran in to this while debugging: https://github.com/mariogintili/async-model/pull/1/files#diff-be9bc2296e644e9cc4c783e51a6a231716c251353aca253effd68264bae589fbR5

what I wrote there:

// routes/application.js
  * This model hook is ran for _every_ route. Because routes are a hierarchy.
   * But because it would be verbose to say 'application.foo', application is
   * omitted from all route names (dot notation).
   *
   * So, we _cannot_ transition away from the application route. I believe this
   * should probably throw an error when transitionTo is called at all from the
   * application route.
   *
   * Instead, what we want to do is transition away *only* if we are not on a sub-route.
   * Like, application.index.

Implementation wise, I don't know if it's possible to know which Route file the transition is called from. but, we could address this with a lint. What do folks think?

NullVoxPopuli avatar Jul 23 '22 17:07 NullVoxPopuli

Could you explain what exactly you want the lint rule to do?

Lint rules know what the current file path is if that helps.

bmish avatar Jul 23 '22 22:07 bmish

yeah, so if a file is app/routes/application.*, we want to lint against using transitionTo in the beforeModel of that route.

NullVoxPopuli avatar Jul 23 '22 23:07 NullVoxPopuli