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

New rule: `no-deprecated-transition-methods`

Open rwjblue opened this issue 4 years ago • 3 comments

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)

rwjblue avatar Jan 21 '21 15:01 rwjblue

name suggestion: prefer-router-service-methods?

jaydgruber avatar Feb 01 '21 04:02 jaydgruber

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

rwjblue avatar Feb 01 '21 15:02 rwjblue

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.

bmish avatar Feb 01 '21 16:02 bmish

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.

rtablada avatar Dec 21 '22 22:12 rtablada