codelyzer icon indicating copy to clipboard operation
codelyzer copied to clipboard

templates-no-negated-async ignores when parens are missing

Open axelboc opened this issue 7 years ago • 0 comments

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.

axelboc avatar Oct 18 '18 09:10 axelboc