Skip to content

Commit

Permalink
refactor(estree-to-babel) set-literal
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jan 28, 2021
1 parent 70a74f3 commit 88338b4
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/set-literal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ module.exports = (node) => {
return;
}

if (node.regex) {
node.type = 'RegExpLiteral';

for (const key of Object.keys(node.regex)) {
node[key] = node.regex[key];
}

delete node.regex;
return;
}

if (isString(value)) {
node.type = 'StringLiteral';
return;
Expand All @@ -38,4 +27,19 @@ module.exports = (node) => {
node.type = 'BooleanLiteral';
return;
}

if (node.regex) {
transformRegExp(node);
return;
}
};

function transformRegExp(node) {
node.type = 'RegExpLiteral';

for (const key of Object.keys(node.regex)) {
node[key] = node.regex[key];
}

delete node.regex;
}

0 comments on commit 88338b4

Please sign in to comment.