@@ -429,6 +429,11 @@ ruleTester.run(`${ruleName}:recommended`, rule, {
429429 // Expressions should pass in recommended mode
430430 { code : '<div role={ROLE_BUTTON} onClick={() => {}} />;' } ,
431431 { 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+ } ,
432437 )
433438 . map ( ruleOptionsMapperFactory ( recommendedOptions ) )
434439 . map ( parserOptionsMapper ) ,
@@ -465,5 +470,11 @@ ruleTester.run(`${ruleName}:strict`, rule, {
465470 // Expressions should fail in strict mode
466471 { code : '<div role={ROLE_BUTTON} onClick={() => {}} />;' , errors : [ expectedError ] } ,
467472 { 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+ } ,
468479 ) . map ( parserOptionsMapper ) ,
469480} ) ;
0 commit comments