-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
New rule: no-implicit-service-injection-argument
#195
Comments
I would love to have this rule, but I don't know about adding to an "on by default" group to start. |
I would personally be against this rule, especially as a default. In my experience people tend to name the same services differently in every component / controller / etc which makes searching for those services tedious. |
Sure it requires consistency in a way, but its hard to follow in the template or elsewhere that you are working with a service. I think this probably won't be a default rule since most people do it the other way. The reason I've submitted this is to help with teams that prefer the more explicit method and aren't used to this kind of "magic". |
Give it a test here #196 |
Related rule: no-unnecessary-service-injection-argument |
FWIW, I would love if this rule existed. |
I'll try to get it across the finish line this week. |
no-implicit-service-injection-argument
I opened a PR to implement |
I'm proposing adding a new Best Practices rule that promotes usage of explicit injections.
So instead of:
The recommended way would be:
The reasoning behind this change, is that I've heard new Ember developers asking about what that means and where is the file that defines the given injection. It's a sort of "black magic" that allows for shortcuts that don't really help down the line. For example:
Now if a new developer saw that in the template, even if there wasn't a model defined, they might think it's the model and try to do
{{#each users as |user|}}
.A better approach:
The above won't prevent users from naming injections poorly, but it will allow them to be more verbose by default.
This rule could have a fix as well, and would open up the way to deprecating the implicit injections all-together, via an RFC. I'm sure that there are also performance improvements when you no longer have to do that implicit check in the internals.
The text was updated successfully, but these errors were encountered: