From cec812d60e3939c35e0924bf32f0e34bc0fc46f5 Mon Sep 17 00:00:00 2001 From: Renato Massao Yonamine Date: Mon, 17 Jun 2024 07:45:36 -0300 Subject: [PATCH] refactor: improve prop values ternary updates --- packages/forma-36-codemod/utils/updateTernaryValues.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/forma-36-codemod/utils/updateTernaryValues.js b/packages/forma-36-codemod/utils/updateTernaryValues.js index 125d214066..75a5e0d413 100644 --- a/packages/forma-36-codemod/utils/updateTernaryValues.js +++ b/packages/forma-36-codemod/utils/updateTernaryValues.js @@ -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]; }; /**