JS.TS.NO.EXTRA.NON.NULL.ASSERTION
Disallow extra non-null assertion
Rule Details
Examples of code for this rule:
<!--tabs-->
Incorrect
Copy
const foo: { bar: number } | null = null;
const bar = foo!!!.bar;
Copy
function foo(bar: number | undefined) {
const bar: number = bar!!!;
}
Copy
function foo(bar?: { n: number }) {
return bar!?.n;
}
Correct
Copy
const foo: { bar: number } | null = null;
const bar = foo!.bar;
Copy
function foo(bar: number | undefined) {
const bar: number = bar!;
}
Copy
function foo(bar?: { n: number }) {
return bar?.n;
}
Options
Copy
// .eslintrc.json
{
"rules": {
"@typescript-eslint/no-extra-non-null-assertion": "error"
}
}
This rule is not configurable.