Skip to content

Commit

Permalink
refactor: improve prop values ternary updates
Browse files Browse the repository at this point in the history
  • Loading branch information
massao committed Jun 17, 2024
1 parent 1f83157 commit cec812d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/forma-36-codemod/utils/updateTernaryValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ function isConditionalExpression(value, j) {
}

const getValueFor = (key, { j, expression, valueMap = {} }) => {
if (isConditionalExpression(expression.value[key], j)) {
return updateTernaryValues(expression, { j, valueMap });
if (valueMap[expression.value[key].value]) {
const value = valueMap[expression.value[key].value];
return value.type === 'Identifier' ? value : j.literal(value);
}

const value =
valueMap[expression.value[key].value] || expression.value[key].value;
return value.type === 'Identifier' ? value : j.literal(value);
return expression.value[key];
};

/**
Expand Down

0 comments on commit cec812d

Please sign in to comment.