codelyzer
codelyzer copied to clipboard
templates-no-negated-async ignores when parens are missing
I just ran into a bug with a negated async pipe. Rule templates-no-negated-async didn't catch it because the parens were missing:
*ngIf="!loading$ | async"
This condition is perfectly valid, but this is not what was intended (a bit like the case of the box in the banana). Moreover, in cases where the parens are purposely left out, there are less confusing ways of implementing the same behaviour (like an extra ng-container with the !loading$ condition on its own).
Therefore, I feel like the templates-no-negated-async rule should be stricter and report async pipes that follow negated observables. To not break current behaviour, this could be implemented as an option.