Skip to content

banana-in-box

Reports a two-way binding written the wrong way round, ([ngModel]). Only in .component.html files.

([x]) is not a binding: Angular reads it as a property binding to a name that does not exist, and the template fails to compile or the binding does nothing.

To fix, write [(ngModel)]: the banana (round) goes in the box (square).

Reported
<input ([ngModel])="a" [(ngModel)]="b" />
...
angular:
lint:
rules:
banana-in-box: error # off, warn, error (default)
html:
lint:
rules:
banana-in-box: error # off, warn, error (default)
svelte:
lint:
rules:
banana-in-box: error # off, warn, error (default)
vue:
lint:
rules:
banana-in-box: error # off, warn, error (default)

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

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

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
angular-eslint banana-in-box full