-
Notifications
You must be signed in to change notification settings - Fork 235
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
Update documentation to show no-element-event-actions
and no-action-modifiers
as related rules
#652
Conversation
`no-element-event-actions` and `no-action-modifiers` appear to be duplicates of eachother
`no-actions-modifiers` and `no-element-event-actions` appear to be duplicates
These rules look like exact opposites. Would love to hear the reasoning behind |
@bmish I've always strongly preferred inline event handlers, and had the impression that many others do as well, so having a linting rule to help enforce it just made sense. Does that answer your question, or were you looking to get into a discussion of why I strongly prefer inline event handlers? |
@bendemboski it would be interesting to hear why you prefer them so that we can document the reasoning in the rule documentation. |
Sure, okay. I guess most basically, it's based on the philosophy that frameworks should identify the pieces of core value they are trying to provide, and for things unrelated to that, they should at most provide the thinnest of wrappers on top of underlying/native functionality even if that leaves warts of the underlying/native functionality exposed. This allows easier adoption because anybody familiar with Javascript/native browser APIs/etc doesn't have to learn a new API/pattern for doing things they already know how to do, easier use by experienced folks because they can maintain simpler mental models of how things work, and easier maintenance of the framework through a smaller API surface area. Philosophy is great, but let's get practical. Using the distinctions that the Deep Dive article made (and adding one additional one that is key to this discussion), we have four types of listeners:
And as the article points out, (3) (and (4)) don't play well with (1) and (2) because of the order that events are delivered. Either combination of (1)/(2) or (3)/(4) can cover all of the use cases (that I've ever encountered at least). So, reasons that IMO (3)/(4) wins out over (1)/(2):
I might be missing some here because I so rarely use them, but the only ways I can come up with that (1)/(2) win out over (3)/(4) are:
In the balance of things, (3)/(4) seem to me to be the far better choice, especially given that sometimes (e.g. third party libraries), the equivalent of (4) is unavoidable even when trying to only use (1)/(2). Moreover, it seems to me that the (3)/(4) story gets even cleaner with element modifiers (e.g. one could use only (4) if they wanted to, and implement all of the benefits of (1)/(2) in userland via some helpers like |
This convo is great! I'm going to go ahead and merge this PR (I think the rules are clearly related, being that they are generally opposites). |
no-element-event-actions
and no-action-modifiers
are now related rulesno-element-event-actions
and no-action-modifiers
as related rules
Both
no-element-event-actions
andno-action-modifiers
essentially do the same thing. I'm adding a note at the bottom of both rules that says they are related.See:
https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-action-modifiers.md
https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-element-event-actions.md