11-- -
22source : crates / biome_js_analyze / tests / spec_tests .rs
3+ assertion_line : 149
34expression : invalidNegatedOrChain .js
45-- -
56# Input
@@ -16,6 +17,10 @@ expression: invalidNegatedOrChain.js
1617!a.b || !a.b();
1718(!foo || !foo.bar) && (!baz || !baz.bar);
1819!foo || !foo?.bar.baz;
20+ !foo || foo.bar !== "x";
21+ !foo || foo.bar != "x";
22+ !foo || "x" !== foo.bar;
23+ !foo || "x" != foo.bar;
1924
2025` ` `
2126
@@ -221,7 +226,7 @@ invalidNegatedOrChain.js:11:2 lint/complexity/useOptionalChain FIXABLE ━━
221226 > 11 │ (!foo || !foo.bar) && (!baz || !baz.bar);
222227 │ ^^^^^^^^^^^^^^^^
223228 12 │ !foo || !foo?.bar.baz;
224- 13 │
229+ 13 │ !foo || foo.bar !== "x";
225230
226231 i Unsafe fix: Change to an optional chain.
227232
@@ -230,7 +235,7 @@ invalidNegatedOrChain.js:11:2 lint/complexity/useOptionalChain FIXABLE ━━
230235 11 │ - (!foo·||·!foo.bar)·&& ·(!baz·||·!baz.bar);
231236 11 │ + (!foo?.bar)·&& ·(!baz·||·!baz.bar);
232237 12 12 │ !foo || !foo?.bar.baz;
233- 13 13 │
238+ 13 13 │ !foo || foo.bar !== "x";
234239
235240
236241` ` `
@@ -245,7 +250,7 @@ invalidNegatedOrChain.js:11:24 lint/complexity/useOptionalChain FIXABLE ━━
245250 > 11 │ (!foo || !foo.bar) && (!baz || !baz.bar);
246251 │ ^^^^^^^^^^^^^^^^
247252 12 │ !foo || !foo?.bar.baz;
248- 13 │
253+ 13 │ !foo || foo.bar !== "x";
249254
250255 i Unsafe fix: Change to an optional chain.
251256
@@ -254,7 +259,7 @@ invalidNegatedOrChain.js:11:24 lint/complexity/useOptionalChain FIXABLE ━━
254259 11 │ - (!foo·||·!foo.bar)·&& ·(!baz·||·!baz.bar);
255260 11 │ + (!foo·||·!foo.bar)·&& ·(!baz?.bar);
256261 12 12 │ !foo || !foo?.bar.baz;
257- 13 13 │
262+ 13 13 │ !foo || foo.bar !== "x";
258263
259264
260265` ` `
@@ -268,11 +273,106 @@ invalidNegatedOrChain.js:12:1 lint/complexity/useOptionalChain FIXABLE ━━
268273 11 │ (!foo || !foo.bar) && (!baz || !baz.bar);
269274 > 12 │ !foo || !foo?.bar.baz;
270275 │ ^^^^^^^^^^^^^^^^^^^^^
271- 13 │
276+ 13 │ !foo || foo.bar !== "x";
277+ 14 │ !foo || foo.bar != "x";
272278
273279 i Unsafe fix: Change to an optional chain.
274280
275281 12 │ !foo·||·!foo?.bar.baz;
276282 │ --------
277283
278284` ` `
285+
286+ ` ` `
287+ invalidNegatedOrChain.js:13:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
288+
289+ ! Change to an optional chain.
290+
291+ 11 │ (!foo || !foo.bar) && (!baz || !baz.bar);
292+ 12 │ !foo || !foo?.bar.baz;
293+ > 13 │ !foo || foo.bar !== "x";
294+ │ ^^^^^^^^^^^^^^^^^^^^^^^
295+ 14 │ !foo || foo.bar != "x";
296+ 15 │ !foo || "x" !== foo.bar;
297+
298+ i Unsafe fix: Change to an optional chain.
299+
300+ 11 11 │ (!foo || !foo.bar) && (!baz || !baz.bar);
301+ 12 12 │ !foo || !foo?.bar.baz;
302+ 13 │ - !foo·||·foo.bar·!==·"x";
303+ 13 │ + foo?.bar·!==·"x";
304+ 14 14 │ !foo || foo.bar != "x";
305+ 15 15 │ !foo || "x" !== foo.bar;
306+
307+
308+ ` ` `
309+
310+ ` ` `
311+ invalidNegatedOrChain.js:14:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
312+
313+ ! Change to an optional chain.
314+
315+ 12 │ !foo || !foo?.bar.baz;
316+ 13 │ !foo || foo.bar !== "x";
317+ > 14 │ !foo || foo.bar != "x";
318+ │ ^^^^^^^^^^^^^^^^^^^^^^
319+ 15 │ !foo || "x" !== foo.bar;
320+ 16 │ !foo || "x" != foo.bar;
321+
322+ i Unsafe fix: Change to an optional chain.
323+
324+ 12 12 │ !foo || !foo?.bar.baz;
325+ 13 13 │ !foo || foo.bar !== "x";
326+ 14 │ - !foo·||·foo.bar·!=·"x";
327+ 14 │ + foo?.bar·!=·"x";
328+ 15 15 │ !foo || "x" !== foo.bar;
329+ 16 16 │ !foo || "x" != foo.bar;
330+
331+
332+ ` ` `
333+
334+ ` ` `
335+ invalidNegatedOrChain.js:15:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
336+
337+ ! Change to an optional chain.
338+
339+ 13 │ !foo || foo.bar !== "x";
340+ 14 │ !foo || foo.bar != "x";
341+ > 15 │ !foo || "x" !== foo.bar;
342+ │ ^^^^^^^^^^^^^^^^^^^^^^^
343+ 16 │ !foo || "x" != foo.bar;
344+ 17 │
345+
346+ i Unsafe fix: Change to an optional chain.
347+
348+ 13 13 │ !foo || foo.bar !== "x";
349+ 14 14 │ !foo || foo.bar != "x";
350+ 15 │ - !foo·||·"x"·!==·foo.bar;
351+ 15 │ + "x"·!==·foo?.bar;
352+ 16 16 │ !foo || "x" != foo.bar;
353+ 17 17 │
354+
355+
356+ ` ` `
357+
358+ ` ` `
359+ invalidNegatedOrChain.js:16:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
360+
361+ ! Change to an optional chain.
362+
363+ 14 │ !foo || foo.bar != "x";
364+ 15 │ !foo || "x" !== foo.bar;
365+ > 16 │ !foo || "x" != foo.bar;
366+ │ ^^^^^^^^^^^^^^^^^^^^^^
367+ 17 │
368+
369+ i Unsafe fix: Change to an optional chain.
370+
371+ 14 14 │ !foo || foo.bar != "x";
372+ 15 15 │ !foo || "x" !== foo.bar;
373+ 16 │ - !foo·||·"x"·!=·foo.bar;
374+ 16 │ + "x"·!=·foo?.bar;
375+ 17 17 │
376+
377+
378+ ` ` `
0 commit comments