@@ -429,11 +429,26 @@ 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
+ // Cases for allowExpressionValues set to true
433
+ {
434
+ code : '<div role={BUTTON} onClick={() => {}} />;' ,
435
+ options : [ { allowExpressionValues : true } ] ,
436
+ } ,
432
437
// Specific case for ternary operator with literals on both side
433
438
{
434
439
code : '<div role={isButton ? "button" : "link"} onClick={() => {}} />;' ,
435
440
options : [ { allowExpressionValues : true } ] ,
436
441
} ,
442
+ {
443
+ code : '<div role={isButton ? "button" : LINK} onClick={() => {}} />;' ,
444
+ options : [ { allowExpressionValues : true } ] ,
445
+ errors : [ expectedError ] ,
446
+ } ,
447
+ {
448
+ code : '<div role={isButton ? BUTTON : LINK} onClick={() => {}} />;' ,
449
+ options : [ { allowExpressionValues : true } ] ,
450
+ errors : [ expectedError ] ,
451
+ } ,
437
452
)
438
453
. map ( ruleOptionsMapperFactory ( recommendedOptions ) )
439
454
. map ( parserOptionsMapper ) ,
@@ -470,6 +485,12 @@ ruleTester.run(`${ruleName}:strict`, rule, {
470
485
// Expressions should fail in strict mode
471
486
{ code : '<div role={ROLE_BUTTON} onClick={() => {}} />;' , errors : [ expectedError ] } ,
472
487
{ code : '<div {...this.props} role={this.props.role} onKeyPress={e => this.handleKeyPress(e)}>{this.props.children}</div>' , errors : [ expectedError ] } ,
488
+ // Cases for allowExpressionValues set to false
489
+ {
490
+ code : '<div role={BUTTON} onClick={() => {}} />;' ,
491
+ options : [ { allowExpressionValues : false } ] ,
492
+ errors : [ expectedError ] ,
493
+ } ,
473
494
// Specific case for ternary operator with literals on both side
474
495
{
475
496
code : '<div role={isButton ? "button" : "link"} onClick={() => {}} />;' ,
0 commit comments