Skip to content

no-extra-non-null-assertion

Reports a second non-null assertion in a row (a!!.b) and a ! right before an optional chain (a!?.b, a!?.()).

The second ! of a!! changes nothing. In a!?.b the ! says the value is not null while ?. says it may be, so one of the two is wrong and the reader cannot tell which.

To fix, remove the extra !, or the ?. if the value cannot be null.

Reported
...
a!!;
a!?.b;
a!?.();
...
js:
lint:
rules:
no-extra-non-null-assertion: warn # off (default), warn, error

Enabled by the presets: js/typescript-eslint-recommended, js/biome-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line no-extra-non-null-assertion in a comment of the file’s language.

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

Tool Rule Match
typescript-eslint no-extra-non-null-assertion full