no-negated-async
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: warnhtml/angular-eslint-recommended
What it does
Section titled “What it does”Reports !(x | async) and (x | async) === false in an Angular template. Only in .component.html files.
Why it matters
Section titled “Why it matters”The async pipe returns null before the stream emits its first value, so the negated test is true while the data is still loading, and the template shows the empty or error state for a moment.
To fix, compare with the value the stream emits, or use @if and @else on the pipe’s result.
Example
Section titled “Example”...<p *ngIf="!(a$ | async)"></p><p [hidden]="(a$ | async) === false || x"></p><p *ngIf="!a$ | async"></p>...Configuration
Section titled “Configuration”angular: lint: rules: no-negated-async: warn # off, warn (default), errorhtml: lint: rules: no-negated-async: warn # off, warn (default), errorsvelte: lint: rules: no-negated-async: warn # off, warn (default), errorvue: lint: rules: no-negated-async: warn # off, warn (default), errorEnabled by the presets: html/angular-eslint-recommended.
Suppress one line with sudsy-disable-next-line no-negated-async in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| angular-eslint | no-negated-async |
partial | !(x | async) and (x | async) === false |