Skip to content

Commit

Permalink
added specific condition
Browse files Browse the repository at this point in the history
  • Loading branch information
V2dha committed Jul 1, 2022
1 parent 1b927ee commit a2c198e
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/rules/no-static-element-interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ export default ({
const { attributes } = node;
const type = elementType(node);

const roleProp = getPropValue(getProp(attributes, 'role'));

const {
allowExpressionValues,
handlers = defaultInteractiveProps,
Expand Down Expand Up @@ -102,18 +100,19 @@ export default ({
allowExpressionValues === true
&& isNonLiteralProperty(attributes, 'role')
) {
// This rule has no opinion about non-literal roles.
return;
}

if (
roleProp === 'ConditionalExpression'
) {
// if (
// roleProp.consequent.type === 'Literal' && role.Prop.alternate.type === 'Literal'
// ) {
// return;
// }
//Special Case if role assignment is done using ternary operator
//with literals on both side
const rolePropVal = getPropValue(getProp(attributes, 'role'));
if (rolePropVal && rolePropVal.type === 'JSXExpressionContainer') {
if (rolePropVal.expression.type === 'ConditionalExpression') {
if (
rolePropVal.expression.consequent.type === 'Literal'
&& rolePropVal.expression.alternate.type === 'Literal'
) {
return;
}
}
}
return;
}

Expand Down

0 comments on commit a2c198e

Please sign in to comment.