diff --git a/crates/rome_js_analyze/tests/specs/nursery/noExtraNonNullAssertion/invalid.ts b/crates/rome_js_analyze/tests/specs/nursery/noExtraNonNullAssertion/invalid.ts index 3c20b3472c09..1db9a2b60969 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/noExtraNonNullAssertion/invalid.ts +++ b/crates/rome_js_analyze/tests/specs/nursery/noExtraNonNullAssertion/invalid.ts @@ -34,3 +34,7 @@ class Case9 { } case10!!.prop = null; + +case11!?.[computedField]; + +case12!?.[a.b!!]; diff --git a/crates/rome_js_analyze/tests/specs/nursery/noExtraNonNullAssertion/invalid.ts.snap b/crates/rome_js_analyze/tests/specs/nursery/noExtraNonNullAssertion/invalid.ts.snap index 428326658663..cc03357b26a9 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/noExtraNonNullAssertion/invalid.ts.snap +++ b/crates/rome_js_analyze/tests/specs/nursery/noExtraNonNullAssertion/invalid.ts.snap @@ -42,6 +42,10 @@ class Case9 { case10!!.prop = null; +case11!?.[computedField]; + +case12!?.[a.b!!]; + ``` # Diagnostics @@ -237,6 +241,7 @@ invalid.ts:36:1 lint/nursery/noExtraNonNullAssertion FIXABLE ━━━━━ > 36 │ case10!!.prop = null; │ ^^^^^^^ 37 │ + 38 │ case11!?.[computedField]; i Safe fix: Remove extra non-null assertion. @@ -245,4 +250,22 @@ invalid.ts:36:1 lint/nursery/noExtraNonNullAssertion FIXABLE ━━━━━ ``` +``` +invalid.ts:40:11 lint/nursery/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Forbidden extra non-null assertion. + + 38 │ case11!?.[computedField]; + 39 │ + > 40 │ case12!?.[a.b!!]; + │ ^^^^ + 41 │ + + i Safe fix: Remove extra non-null assertion. + + 40 │ case12!?.[a.b!!]; + │ - + +``` +