File tree Expand file tree Collapse file tree 2 files changed +67
-1
lines changed
Expand file tree Collapse file tree 2 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,13 @@ function isConditionalTest(node: TSESTree.Node): boolean {
476476 return isConditionalTest ( parent ) ;
477477 }
478478
479+ if (
480+ parent . type === AST_NODE_TYPES . UnaryExpression &&
481+ parent . operator === '!'
482+ ) {
483+ return isConditionalTest ( parent ) ;
484+ }
485+
479486 if (
480487 ( parent . type === AST_NODE_TYPES . ConditionalExpression ||
481488 parent . type === AST_NODE_TYPES . DoWhileStatement ||
Original file line number Diff line number Diff line change @@ -575,6 +575,34 @@ let b: string | boolean | undefined;
575575let c: string | boolean | undefined;
576576
577577if (((a = b), b || c)) {
578+ }
579+ ` ,
580+ options : [
581+ {
582+ ignoreConditionalTests : true ,
583+ } ,
584+ ] ,
585+ } ,
586+ {
587+ code : `
588+ let a: string | undefined;
589+ let b: string | undefined;
590+
591+ if (!(a || b)) {
592+ }
593+ ` ,
594+ options : [
595+ {
596+ ignoreConditionalTests : true ,
597+ } ,
598+ ] ,
599+ } ,
600+ {
601+ code : `
602+ let a: string | undefined;
603+ let b: string | undefined;
604+
605+ if (!!(a || b)) {
578606}
579607 ` ,
580608 options : [
@@ -2266,7 +2294,38 @@ if (f(a ?? b)) {
22662294 ] ,
22672295 options : [
22682296 {
2269- ignoreBooleanCoercion : true ,
2297+ ignoreConditionalTests : true ,
2298+ } ,
2299+ ] ,
2300+ } ,
2301+ {
2302+ code : `
2303+ declare const a: string | undefined;
2304+ declare const b: string;
2305+
2306+ if (+(a || b)) {
2307+ }
2308+ ` ,
2309+ errors : [
2310+ {
2311+ messageId : 'preferNullishOverOr' ,
2312+ suggestions : [
2313+ {
2314+ messageId : 'suggestNullish' ,
2315+ output : `
2316+ declare const a: string | undefined;
2317+ declare const b: string;
2318+
2319+ if (+(a ?? b)) {
2320+ }
2321+ ` ,
2322+ } ,
2323+ ] ,
2324+ } ,
2325+ ] ,
2326+ options : [
2327+ {
2328+ ignoreConditionalTests : true ,
22702329 } ,
22712330 ] ,
22722331 } ,
You can’t perform that action at this time.
0 commit comments