no-extra-non-null-assertion
JavaScript / TypeScriptsuspiciousno fixdefault: offjs/typescript-eslint-recommendedjs/biome-recommendedjs/oxlint
What it does
Section titled “What it does”Reports a second non-null assertion in a row (a!!.b) and a ! right before an optional chain (a!?.b, a!?.()).
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”...a!!;a!?.b;a!?.();...Configuration
Section titled “Configuration”js: lint: rules: no-extra-non-null-assertion: warn # off (default), warn, errorEnabled 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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| typescript-eslint | no-extra-non-null-assertion |
full |