Skip to content

eqeqeq

Reports == and != in the bindings, interpolations and block parameters of an Angular template. Only in .component.html files.

The loose operators convert their operands before they compare, so 0 == '' and null == undefined are true and the template shows content for a value the author did not mean.

To fix, write === and !==.

Reported
...
<p *ngIf="a == b && c !== d">{{ a != b ? "x == y" : 1 }}</p>
...
<p *ngIf="!a$ | async"></p>
@if (a == 1) { <b></b> }
...
@for (x of xs; track x.id) { <i></i> }
angular:
lint:
rules:
eqeqeq: warn # off, warn (default), error
html:
lint:
rules:
eqeqeq: warn # off, warn (default), error
svelte:
lint:
rules:
eqeqeq: warn # off, warn (default), error
vue:
lint:
rules:
eqeqeq: warn # off, warn (default), error

Enabled by the presets: html/angular-eslint-recommended.

Suppress one line with sudsy-disable-next-line eqeqeq in a comment of the file’s language.

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 eqeqeq partial allowNullOrUndefined is not an option