-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement no-route-action
rule
#2030
Implement no-route-action
rule
#2030
Conversation
I think this is a fantastic rule because, despite still being on Ember 2.14, having no updates in the last 2 years, and having had a warning in its README telling people not to use it for the last 4 years, It's clear that this is a common problem that would help the community by adding an optional lint rule, and rules like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about trying to contact the maintainers and see if the addon can officially be deprecated?
@bertdeblock I filed this ticket to see if the maintainers are willing to take action on that suggestion: DockYard/ember-route-action-helper#109 |
@bertdeblock great suggestion, thanks @elwayman02 for sending the request out! |
Co-authored-by: Tyler Becks <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good overall. I do think it a bit odd to use function.bind rather than methods of the class in the rules, and using a bespoke string replacement mechanism for the error message, but I realize you're just following the pattern in no-action
, so I wouldn't suggest changing it now.
Thanks for adding this!
It's possible there's more test cases we could/should add, but I'm comfortable merging this for now with an eye to expanding those cases as they arise. |
The addon doesn't contain a |
No reason, that is a mistake. As @scalvert mentioned, I based on this from I will remove it and put out a PR soon, thanks. |
@thiagofesta before we called route-actions in child routes, and the action was declared at the top route level, for example:
please tell me what is the best practice in this case now |
no-route-action
This rule disallows the usage of
route-action
.ember-route-action-helper was a popular addon used to add actions to a route without creating a separate controller. Given the changes in Ember since ember-route-action-helper was a widely used pattern, controllers are now encouraged and we want to discourage the use of route-action.
Most route actions should either be sent to the controller first or encapsulated within a downstream component instead. We should never be escaping the DDAU hierarchy to lob actions up to the route.
Examples
This rule forbids the following:
With the given route:
This rule allows the following:
With the given controller:
Migration
The example below shows how to migrate from route-action to controller actions.
Before
After
References