--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: logicalAndCases5.js --- # Input ```jsx // case with a jump (i.e. a non-nullish prop) foo != null && foo.bar != null && foo.bar.baz.buzz foo.bar != null && foo.bar.baz.buzz // case where for some reason there is a doubled up expression foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz // chained members with element access foo != null && foo[bar] != null && foo[bar].baz != null && foo[bar].baz.buzz // case with a jump (i.e. a non-nullish prop) foo != null && foo[bar].baz != null && foo[bar].baz.buzz // chained calls foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz() foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() // case with a jump (i.e. a non-nullish prop) foo != null && foo.bar != null && foo.bar.baz.buzz() foo.bar != null && foo.bar.baz.buzz() // case with a jump (i.e. a non-nullish prop) foo != null && foo.bar != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() // case with a call expr inside the chain for some inefficient reason foo != null && foo.bar() != null && foo.bar().baz != null && foo.bar().baz.buzz != null && foo.bar().baz.buzz() // chained calls with element access foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz]() foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz] != null && foo.bar.baz[buzz]() // (partially) pre-optional chained foo != null && foo?.bar != null && foo?.bar.baz != null && foo?.bar.baz[buzz] != null && foo?.bar.baz[buzz]() foo != null && foo?.bar.baz != null && foo?.bar.baz[buzz] foo != null && foo?.() != null && foo?.().bar foo.bar != null && foo.bar?.() != null && foo.bar?.().baz // chained members foo != undefined && foo.bar foo.bar != undefined && foo.bar.baz foo != undefined && foo() foo.bar != undefined && foo.bar() foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz // case with a jump (i.e. a non-nullish prop) foo != undefined && foo.bar != undefined && foo.bar.baz.buzz foo.bar != undefined && foo.bar.baz.buzz // case where for some reason there is a doubled up expression foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz // chained members with element access foo != undefined && foo[bar] != undefined && foo[bar].baz != undefined && foo[bar].baz.buzz // case with a jump (i.e. a non-nullish prop) foo != undefined && foo[bar].baz != undefined && foo[bar].baz.buzz // chained calls foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz() foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() ``` # Diagnostics ``` logicalAndCases5.js:2:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 1 │ // case with a jump (i.e. a non-nullish prop) > 2 │ foo != null && foo.bar != null && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 │ foo.bar != null && foo.bar.baz.buzz 4 │ i Unsafe fix: Change to an optional chain. 1 1 │ // case with a jump (i.e. a non-nullish prop) 2 │ - foo·!=·null·&&·foo.bar·!=·null·&&·foo.bar.baz.buzz 2 │ + foo?.bar?.baz.buzz 3 3 │ foo.bar != null && foo.bar.baz.buzz 4 4 │ ``` ``` logicalAndCases5.js:3:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 1 │ // case with a jump (i.e. a non-nullish prop) 2 │ foo != null && foo.bar != null && foo.bar.baz.buzz > 3 │ foo.bar != null && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 │ 5 │ // case where for some reason there is a doubled up expression i Unsafe fix: Change to an optional chain. 1 1 │ // case with a jump (i.e. a non-nullish prop) 2 2 │ foo != null && foo.bar != null && foo.bar.baz.buzz 3 │ - foo.bar·!=·null·&&·foo.bar.baz.buzz 3 │ + foo.bar?.baz.buzz 4 4 │ 5 5 │ // case where for some reason there is a doubled up expression ``` ``` logicalAndCases5.js:6:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 5 │ // case where for some reason there is a doubled up expression > 6 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz 8 │ i Unsafe fix: Change to an optional chain. 4 4 │ 5 5 │ // case where for some reason there is a doubled up expression 6 │ - foo·!=·null·&&·foo.bar·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz.buzz 6 │ + foo?.bar?.baz?.buzz 7 7 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz 8 8 │ ``` ``` logicalAndCases5.js:7:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 5 │ // case where for some reason there is a doubled up expression 6 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz > 7 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 │ 9 │ // chained members with element access i Unsafe fix: Change to an optional chain. 5 5 │ // case where for some reason there is a doubled up expression 6 6 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz 7 │ - foo.bar·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz.buzz 7 │ + foo.bar?.baz?.buzz 8 8 │ 9 9 │ // chained members with element access ``` ``` logicalAndCases5.js:10:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 9 │ // chained members with element access > 10 │ foo != null && foo[bar] != null && foo[bar].baz != null && foo[bar].baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 │ 12 │ // case with a jump (i.e. a non-nullish prop) i Unsafe fix: Change to an optional chain. 8 8 │ 9 9 │ // chained members with element access 10 │ - foo·!=·null·&&·foo[bar]·!=·null·&&·foo[bar].baz·!=·null·&&·foo[bar].baz.buzz 10 │ + foo?.[bar]?.baz?.buzz 11 11 │ 12 12 │ // case with a jump (i.e. a non-nullish prop) ``` ``` logicalAndCases5.js:13:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 12 │ // case with a jump (i.e. a non-nullish prop) > 13 │ foo != null && foo[bar].baz != null && foo[bar].baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 │ 15 │ // chained calls i Unsafe fix: Change to an optional chain. 11 11 │ 12 12 │ // case with a jump (i.e. a non-nullish prop) 13 │ - foo·!=·null·&&·foo[bar].baz·!=·null·&&·foo[bar].baz.buzz 13 │ + foo?.[bar].baz?.buzz 14 14 │ 15 15 │ // chained calls ``` ``` logicalAndCases5.js:16:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 15 │ // chained calls > 16 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() 18 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() i Unsafe fix: Change to an optional chain. 14 14 │ 15 15 │ // chained calls 16 │ - foo·!=·null·&&·foo.bar·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz.buzz() 16 │ + foo?.bar?.baz?.buzz() 17 17 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() 18 18 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() ``` ``` logicalAndCases5.js:17:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 15 │ // chained calls 16 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz() > 17 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() 19 │ i Unsafe fix: Change to an optional chain. 15 15 │ // chained calls 16 16 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz() 17 │ - foo·!=·null·&&·foo.bar·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz.buzz·!=·null·&&·foo.bar.baz.buzz() 17 │ + foo?.bar?.baz?.buzz?.() 18 18 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() 19 19 │ ``` ``` logicalAndCases5.js:18:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 16 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz() 17 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() > 18 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 │ 20 │ // case with a jump (i.e. a non-nullish prop) i Unsafe fix: Change to an optional chain. 16 16 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz() 17 17 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() 18 │ - foo.bar·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz.buzz·!=·null·&&·foo.bar.baz.buzz() 18 │ + foo.bar?.baz?.buzz?.() 19 19 │ 20 20 │ // case with a jump (i.e. a non-nullish prop) ``` ``` logicalAndCases5.js:21:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 20 │ // case with a jump (i.e. a non-nullish prop) > 21 │ foo != null && foo.bar != null && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 │ foo.bar != null && foo.bar.baz.buzz() 23 │ i Unsafe fix: Change to an optional chain. 19 19 │ 20 20 │ // case with a jump (i.e. a non-nullish prop) 21 │ - foo·!=·null·&&·foo.bar·!=·null·&&·foo.bar.baz.buzz() 21 │ + foo?.bar?.baz.buzz() 22 22 │ foo.bar != null && foo.bar.baz.buzz() 23 23 │ ``` ``` logicalAndCases5.js:22:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 20 │ // case with a jump (i.e. a non-nullish prop) 21 │ foo != null && foo.bar != null && foo.bar.baz.buzz() > 22 │ foo.bar != null && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 │ 24 │ // case with a jump (i.e. a non-nullish prop) i Unsafe fix: Change to an optional chain. 20 20 │ // case with a jump (i.e. a non-nullish prop) 21 21 │ foo != null && foo.bar != null && foo.bar.baz.buzz() 22 │ - foo.bar·!=·null·&&·foo.bar.baz.buzz() 22 │ + foo.bar?.baz.buzz() 23 23 │ 24 24 │ // case with a jump (i.e. a non-nullish prop) ``` ``` logicalAndCases5.js:25:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 24 │ // case with a jump (i.e. a non-nullish prop) > 25 │ foo != null && foo.bar != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 │ 27 │ // case with a call expr inside the chain for some inefficient reason i Unsafe fix: Change to an optional chain. 23 23 │ 24 24 │ // case with a jump (i.e. a non-nullish prop) 25 │ - foo·!=·null·&&·foo.bar·!=·null·&&·foo.bar.baz.buzz·!=·null·&&·foo.bar.baz.buzz() 25 │ + foo?.bar?.baz.buzz?.() 26 26 │ 27 27 │ // case with a call expr inside the chain for some inefficient reason ``` ``` logicalAndCases5.js:28:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 27 │ // case with a call expr inside the chain for some inefficient reason > 28 │ foo != null && foo.bar() != null && foo.bar().baz != null && foo.bar().baz.buzz != null && foo.bar().baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 │ 30 │ // chained calls with element access i Unsafe fix: Change to an optional chain. 26 26 │ 27 27 │ // case with a call expr inside the chain for some inefficient reason 28 │ - foo·!=·null·&&·foo.bar()·!=·null·&&·foo.bar().baz·!=·null·&&·foo.bar().baz.buzz·!=·null·&&·foo.bar().baz.buzz() 28 │ + foo?.bar()?.baz?.buzz?.() 29 29 │ 30 30 │ // chained calls with element access ``` ``` logicalAndCases5.js:31:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 30 │ // chained calls with element access > 31 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz]() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz] != null && foo.bar.baz[buzz]() 33 │ i Unsafe fix: Change to an optional chain. 29 29 │ 30 30 │ // chained calls with element access 31 │ - foo·!=·null·&&·foo.bar·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz[buzz]() 31 │ + foo?.bar?.baz?.[buzz]() 32 32 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz] != null && foo.bar.baz[buzz]() 33 33 │ ``` ``` logicalAndCases5.js:32:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 30 │ // chained calls with element access 31 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz]() > 32 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz] != null && foo.bar.baz[buzz]() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 │ 34 │ // (partially) pre-optional chained i Unsafe fix: Change to an optional chain. 30 30 │ // chained calls with element access 31 31 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz]() 32 │ - foo·!=·null·&&·foo.bar·!=·null·&&·foo.bar.baz·!=·null·&&·foo.bar.baz[buzz]·!=·null·&&·foo.bar.baz[buzz]() 32 │ + foo?.bar?.baz?.[buzz]?.() 33 33 │ 34 34 │ // (partially) pre-optional chained ``` ``` logicalAndCases5.js:35:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 34 │ // (partially) pre-optional chained > 35 │ foo != null && foo?.bar != null && foo?.bar.baz != null && foo?.bar.baz[buzz] != null && foo?.bar.baz[buzz]() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 │ foo != null && foo?.bar.baz != null && foo?.bar.baz[buzz] 37 │ foo != null && foo?.() != null && foo?.().bar i Unsafe fix: Change to an optional chain. 33 33 │ 34 34 │ // (partially) pre-optional chained 35 │ - foo·!=·null·&&·foo?.bar·!=·null·&&·foo?.bar.baz·!=·null·&&·foo?.bar.baz[buzz]·!=·null·&&·foo?.bar.baz[buzz]() 35 │ + foo?.bar?.baz?.[buzz]?.() 36 36 │ foo != null && foo?.bar.baz != null && foo?.bar.baz[buzz] 37 37 │ foo != null && foo?.() != null && foo?.().bar ``` ``` logicalAndCases5.js:36:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 34 │ // (partially) pre-optional chained 35 │ foo != null && foo?.bar != null && foo?.bar.baz != null && foo?.bar.baz[buzz] != null && foo?.bar.baz[buzz]() > 36 │ foo != null && foo?.bar.baz != null && foo?.bar.baz[buzz] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 │ foo != null && foo?.() != null && foo?.().bar 38 │ foo.bar != null && foo.bar?.() != null && foo.bar?.().baz i Unsafe fix: Change to an optional chain. 36 │ foo·!=·null·&&·foo?.bar.baz·!=·null·&&·foo?.bar.baz[buzz] │ --------------- --------------- ------- ``` ``` logicalAndCases5.js:37:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 35 │ foo != null && foo?.bar != null && foo?.bar.baz != null && foo?.bar.baz[buzz] != null && foo?.bar.baz[buzz]() 36 │ foo != null && foo?.bar.baz != null && foo?.bar.baz[buzz] > 37 │ foo != null && foo?.() != null && foo?.().bar │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 │ foo.bar != null && foo.bar?.() != null && foo.bar?.().baz 39 │ i Unsafe fix: Change to an optional chain. 37 │ foo·!=·null·&&·foo?.()·!=·null·&&·foo?.().bar │ --------------- --------------- --- ``` ``` logicalAndCases5.js:38:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 36 │ foo != null && foo?.bar.baz != null && foo?.bar.baz[buzz] 37 │ foo != null && foo?.() != null && foo?.().bar > 38 │ foo.bar != null && foo.bar?.() != null && foo.bar?.().baz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 │ 40 │ // chained members i Unsafe fix: Change to an optional chain. 38 │ foo.bar·!=·null·&&·foo.bar?.()·!=·null·&&·foo.bar?.().baz │ ------------------- ------------------- --- ``` ``` logicalAndCases5.js:41:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 40 │ // chained members > 41 │ foo != undefined && foo.bar │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 │ foo.bar != undefined && foo.bar.baz 43 │ foo != undefined && foo() i Unsafe fix: Change to an optional chain. 39 39 │ 40 40 │ // chained members 41 │ - foo·!=·undefined·&&·foo.bar 41 │ + foo?.bar 42 42 │ foo.bar != undefined && foo.bar.baz 43 43 │ foo != undefined && foo() ``` ``` logicalAndCases5.js:42:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 40 │ // chained members 41 │ foo != undefined && foo.bar > 42 │ foo.bar != undefined && foo.bar.baz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 │ foo != undefined && foo() 44 │ foo.bar != undefined && foo.bar() i Unsafe fix: Change to an optional chain. 40 40 │ // chained members 41 41 │ foo != undefined && foo.bar 42 │ - foo.bar·!=·undefined·&&·foo.bar.baz 42 │ + foo.bar?.baz 43 43 │ foo != undefined && foo() 44 44 │ foo.bar != undefined && foo.bar() ``` ``` logicalAndCases5.js:43:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 41 │ foo != undefined && foo.bar 42 │ foo.bar != undefined && foo.bar.baz > 43 │ foo != undefined && foo() │ ^^^^^^^^^^^^^^^^^^^^^^^^^ 44 │ foo.bar != undefined && foo.bar() 45 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz i Unsafe fix: Change to an optional chain. 41 41 │ foo != undefined && foo.bar 42 42 │ foo.bar != undefined && foo.bar.baz 43 │ - foo·!=·undefined·&&·foo() 43 │ + foo?.() 44 44 │ foo.bar != undefined && foo.bar() 45 45 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz ``` ``` logicalAndCases5.js:44:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 42 │ foo.bar != undefined && foo.bar.baz 43 │ foo != undefined && foo() > 44 │ foo.bar != undefined && foo.bar() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz 46 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz i Unsafe fix: Change to an optional chain. 42 42 │ foo.bar != undefined && foo.bar.baz 43 43 │ foo != undefined && foo() 44 │ - foo.bar·!=·undefined·&&·foo.bar() 44 │ + foo.bar?.() 45 45 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz 46 46 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz ``` ``` logicalAndCases5.js:45:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 43 │ foo != undefined && foo() 44 │ foo.bar != undefined && foo.bar() > 45 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz 47 │ i Unsafe fix: Change to an optional chain. 43 43 │ foo != undefined && foo() 44 44 │ foo.bar != undefined && foo.bar() 45 │ - foo·!=·undefined·&&·foo.bar·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz.buzz 45 │ + foo?.bar?.baz?.buzz 46 46 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz 47 47 │ ``` ``` logicalAndCases5.js:46:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 44 │ foo.bar != undefined && foo.bar() 45 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz > 46 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 │ 48 │ // case with a jump (i.e. a non-nullish prop) i Unsafe fix: Change to an optional chain. 44 44 │ foo.bar != undefined && foo.bar() 45 45 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz 46 │ - foo.bar·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz.buzz 46 │ + foo.bar?.baz?.buzz 47 47 │ 48 48 │ // case with a jump (i.e. a non-nullish prop) ``` ``` logicalAndCases5.js:49:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 48 │ // case with a jump (i.e. a non-nullish prop) > 49 │ foo != undefined && foo.bar != undefined && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 │ foo.bar != undefined && foo.bar.baz.buzz 51 │ i Unsafe fix: Change to an optional chain. 47 47 │ 48 48 │ // case with a jump (i.e. a non-nullish prop) 49 │ - foo·!=·undefined·&&·foo.bar·!=·undefined·&&·foo.bar.baz.buzz 49 │ + foo?.bar?.baz.buzz 50 50 │ foo.bar != undefined && foo.bar.baz.buzz 51 51 │ ``` ``` logicalAndCases5.js:50:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 48 │ // case with a jump (i.e. a non-nullish prop) 49 │ foo != undefined && foo.bar != undefined && foo.bar.baz.buzz > 50 │ foo.bar != undefined && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 51 │ 52 │ // case where for some reason there is a doubled up expression i Unsafe fix: Change to an optional chain. 48 48 │ // case with a jump (i.e. a non-nullish prop) 49 49 │ foo != undefined && foo.bar != undefined && foo.bar.baz.buzz 50 │ - foo.bar·!=·undefined·&&·foo.bar.baz.buzz 50 │ + foo.bar?.baz.buzz 51 51 │ 52 52 │ // case where for some reason there is a doubled up expression ``` ``` logicalAndCases5.js:53:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 52 │ // case where for some reason there is a doubled up expression > 53 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz 55 │ i Unsafe fix: Change to an optional chain. 51 51 │ 52 52 │ // case where for some reason there is a doubled up expression 53 │ - foo·!=·undefined·&&·foo.bar·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz.buzz 53 │ + foo?.bar?.baz?.buzz 54 54 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz 55 55 │ ``` ``` logicalAndCases5.js:54:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 52 │ // case where for some reason there is a doubled up expression 53 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz > 54 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 │ 56 │ // chained members with element access i Unsafe fix: Change to an optional chain. 52 52 │ // case where for some reason there is a doubled up expression 53 53 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz 54 │ - foo.bar·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz.buzz 54 │ + foo.bar?.baz?.buzz 55 55 │ 56 56 │ // chained members with element access ``` ``` logicalAndCases5.js:57:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 56 │ // chained members with element access > 57 │ foo != undefined && foo[bar] != undefined && foo[bar].baz != undefined && foo[bar].baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 58 │ 59 │ // case with a jump (i.e. a non-nullish prop) i Unsafe fix: Change to an optional chain. 55 55 │ 56 56 │ // chained members with element access 57 │ - foo·!=·undefined·&&·foo[bar]·!=·undefined·&&·foo[bar].baz·!=·undefined·&&·foo[bar].baz.buzz 57 │ + foo?.[bar]?.baz?.buzz 58 58 │ 59 59 │ // case with a jump (i.e. a non-nullish prop) ``` ``` logicalAndCases5.js:60:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 59 │ // case with a jump (i.e. a non-nullish prop) > 60 │ foo != undefined && foo[bar].baz != undefined && foo[bar].baz.buzz │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 │ 62 │ // chained calls i Unsafe fix: Change to an optional chain. 58 58 │ 59 59 │ // case with a jump (i.e. a non-nullish prop) 60 │ - foo·!=·undefined·&&·foo[bar].baz·!=·undefined·&&·foo[bar].baz.buzz 60 │ + foo?.[bar].baz?.buzz 61 61 │ 62 62 │ // chained calls ``` ``` logicalAndCases5.js:63:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 62 │ // chained calls > 63 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() 65 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() i Unsafe fix: Change to an optional chain. 61 61 │ 62 62 │ // chained calls 63 │ - foo·!=·undefined·&&·foo.bar·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz.buzz() 63 │ + foo?.bar?.baz?.buzz() 64 64 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() 65 65 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() ``` ``` logicalAndCases5.js:64:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 62 │ // chained calls 63 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz() > 64 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() 66 │ i Unsafe fix: Change to an optional chain. 62 62 │ // chained calls 63 63 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz() 64 │ - foo·!=·undefined·&&·foo.bar·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz.buzz·!=·undefined·&&·foo.bar.baz.buzz() 64 │ + foo?.bar?.baz?.buzz?.() 65 65 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() 66 66 │ ``` ``` logicalAndCases5.js:65:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 63 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz() 64 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() > 65 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 │ i Unsafe fix: Change to an optional chain. 63 63 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz() 64 64 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() 65 │ - foo.bar·!=·undefined·&&·foo.bar.baz·!=·undefined·&&·foo.bar.baz.buzz·!=·undefined·&&·foo.bar.baz.buzz() 65 │ + foo.bar?.baz?.buzz?.() 66 66 │ ```