Open etramell opened 6 years ago
Followup: I have been trying to figure out a commonality between the events that get visited, vs. those that don't, and I think I have it...
In our project, we (very!) often format our HTML like this to avoid long unreadable lines:
<some-component
[input1]="true"
[input2]="42"
(output1)="onOutput1()"
(output2)="onOutput2()">
</some-component>
instead of:
<some-component [input1]="true" [input2]="42" (output1)="onOutput1()" (output2)="onOutput2()"></some-component>
It appears that the only events that get visited are the ones in HTML like the latter. Events in HTML like the former are not visited.
Given that, is this a bug that can be fixed?
@etramell-tem thanks for reporting the issue! I'll look at it over the weekend.
What I'm trying to do: Write a custom rule that enforces event handler naming consistency, by copying and modifying the code from banana-in-box.
Problem: The custom rule is not visiting most Angular template events, by which I mean bindings like
(event)="handler()"
.Minimal example: I've stripped away all the functionality in this rule except for logging the visited event's name (this is the entire TypeScript source file):
Output:
(Actually, it looks like the events being visited are being visited twice each for whatever reason. Don't know if that's relevant, so I left the duplicate output in there just in case.)
Expected Output: We have many
EventEmitter
handlers defined in our templates, and none of them show up in this output. Furthermore, our project has 227(click)
handlers defined, and the output above doesn't list anywhere close to that many.Further troubleshooting: I created another temporary custom rule by copying
banana-in-box
itself, renaming it to justbanana
, and adding the sameconsole.log()
. I get the same exact output from both of these test rules. In addition, I purposely "put a box inside a banana" and it's not being reported (bothbanana-in-box
and this temporarybanana
are configured astrue
).Versions: Angular 6 and Codelyzer 4.4.2.
Any ideas? Thanks!
- Ed