Skip to content

Commit

Permalink
fix: do not inline regexp literal when declaration in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Mar 27, 2020
1 parent 3429ac2 commit b1cf7bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function f(query) {
var r = /./g,
part;
while (part = r.exec(query));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function f(query) {
var r = /./g,
part;

while (part = r.exec(query));
}
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ module.exports = ({ types: t, traverse }) => {
const isObj = n =>
t.isFunction(n) ||
t.isObjectExpression(n) ||
t.isArrayExpression(n);
t.isArrayExpression(n) ||
t.isRegExpLiteral(n);

const isReplacementObj =
isObj(replacement) || some(replacement, isObj);
Expand Down

0 comments on commit b1cf7bf

Please sign in to comment.