eslint-plugin-ember
eslint-plugin-ember copied to clipboard
New rule: `no-deprecated-transition-methods`
Adds a nice way to handle emberjs/rfcs#674 by flagging them as an issue, and adding a fixer to use the router service.
This would flag:
- Using
this.transitionTo
from a route - Using
this.replaceWith
from a route - Using
this.transitionToRoute
from a controller - Using
this.replaceRoute
from a controller
The fixer would be:
-
this.transitionTo
-> adding router service +this.router.transitionTo
-
this.replaceWith
-> adding router service +this.router.replaceWith
-
this.transitionToRoute
-> adding router service +this.router.transitionTo
-
this.replaceRoute
-> adding router service +this.router.replaceWith
The deprecation was implemented in https://github.com/emberjs/ember.js/pull/19255 and will be included in Ember 3.26.
(note: I'm not super in love with the name)
name suggestion: prefer-router-service-methods
?
Ya, I'm not super sold on my original name suggestion here. The thing that I want to make clear though, is that this is about deprecation avoidance (not a general preference / stylistic thing).
@bmish probably has a better handle on existing naming scheme for us to follow here
Agreed with @rwjblue that the name should state of the goal of deprecation avoidance. So no-deprecated-transition-methods
or possibly no-deprecated-router-transition-methods
would be even more clear.
We're hitting the same deprecation. While it seems like the deprecation is pushed back a while, this is an easy lint/codemod candidate.
I implemented a similar rule with class state, adding service injection, etc in #1714 so I think I can knock this one out pretty easily.