@@ -65,8 +65,28 @@ ruleTester.run(`${ruleName}:recommended`, rule, {
6565 valid : [
6666 ...alwaysValid ,
6767 { code : '<div role="tabpanel" tabIndex="0" />' } ,
68- // Expressions should fail in strict mode
68+ // Expressions should pass in recommended mode
6969 { code : '<div role={ROLE_BUTTON} onClick={() => {}} tabIndex="0" />;' } ,
70+ // Cases for allowExpressionValues set to true
71+ {
72+ code : '<div role={BUTTON} onClick={() => {}} tabIndex="0" />;' ,
73+ options : [ { allowExpressionValues : true } ] ,
74+ } ,
75+ // Specific case for ternary operator with literals on both side
76+ {
77+ code : '<div role={isButton ? "button" : "link"} onClick={() => {}} tabIndex="0" />;' ,
78+ options : [ { allowExpressionValues : true } ] ,
79+ } ,
80+ {
81+ code : '<div role={isButton ? "button" : LINK} onClick={() => {}} tabIndex="0" />;' ,
82+ options : [ { allowExpressionValues : true } ] ,
83+ errors : [ expectedError ] ,
84+ } ,
85+ {
86+ code : '<div role={isButton ? BUTTON : LINK} onClick={() => {}} tabIndex="0"/>;' ,
87+ options : [ { allowExpressionValues : true } ] ,
88+ errors : [ expectedError ] ,
89+ } ,
7090 ]
7191 . map ( ruleOptionsMapperFactory ( recommendedOptions ) )
7292 . map ( parserOptionsMapper ) ,
@@ -86,5 +106,17 @@ ruleTester.run(`${ruleName}:strict`, rule, {
86106 { code : '<div role="tabpanel" tabIndex="0" />' , errors : [ expectedError ] } ,
87107 // Expressions should fail in strict mode
88108 { code : '<div role={ROLE_BUTTON} onClick={() => {}} tabIndex="0" />;' , errors : [ expectedError ] } ,
109+ // Cases for allowExpressionValues set to false
110+ {
111+ code : '<div role={BUTTON} onClick={() => {}} tabIndex="0" />;' ,
112+ options : [ { allowExpressionValues : false } ] ,
113+ errors : [ expectedError ] ,
114+ } ,
115+ // Specific case for ternary operator with literals on both side
116+ {
117+ code : '<div role={isButton ? "button" : "link"} onClick={() => {}} tabIndex="0" />;' ,
118+ options : [ { allowExpressionValues : false } ] ,
119+ errors : [ expectedError ] ,
120+ } ,
89121 ] . map ( parserOptionsMapper ) ,
90122} ) ;
0 commit comments