@@ -429,6 +429,11 @@ ruleTester.run(`${ruleName}:recommended`, rule, {
429
429
// Expressions should pass in recommended mode
430
430
{ code : '<div role={ROLE_BUTTON} onClick={() => {}} />;' } ,
431
431
{ code : '<div {...this.props} role={this.props.role} onKeyPress={e => this.handleKeyPress(e)}>{this.props.children}</div>' } ,
432
+ // Specific case for ternary operator with literals on both side
433
+ {
434
+ code : '<div role={isButton ? "button" : "link"} onClick={() => {}} />;' ,
435
+ options : [ { allowExpressionValues : true } ] ,
436
+ } ,
432
437
)
433
438
. map ( ruleOptionsMapperFactory ( recommendedOptions ) )
434
439
. map ( parserOptionsMapper ) ,
@@ -465,5 +470,11 @@ ruleTester.run(`${ruleName}:strict`, rule, {
465
470
// Expressions should fail in strict mode
466
471
{ code : '<div role={ROLE_BUTTON} onClick={() => {}} />;' , errors : [ expectedError ] } ,
467
472
{ code : '<div {...this.props} role={this.props.role} onKeyPress={e => this.handleKeyPress(e)}>{this.props.children}</div>' , errors : [ expectedError ] } ,
473
+ // Specific case for ternary operator with literals on both side
474
+ {
475
+ code : '<div role={isButton ? "button" : "link"} onClick={() => {}} />;' ,
476
+ options : [ { allowExpressionValues : false } ] ,
477
+ errors : [ expectedError ] ,
478
+ } ,
468
479
) . map ( parserOptionsMapper ) ,
469
480
} ) ;
0 commit comments