Skip to content

Commit

Permalink
Do not inline RegExp literals in loop assignment
Browse files Browse the repository at this point in the history
Do not inline RegExp literals in loop assignment
  • Loading branch information
JLHwung authored May 4, 2022
2 parents 1ad7838 + 2209048 commit f051377
Show file tree
Hide file tree
Showing 9 changed files with 1,769 additions and 2,070 deletions.
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
"watch": "gulp watch"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/plugin-transform-block-scoping": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"@babel/core": "^7.9.0",
"@babel/plugin-transform-block-scoping": "^7.8.3",
"@babel/preset-env": "^7.9.0",
"babel-jest": "^24.9.0",
"butternut": "^0.4.6",
"bytes": "^3.0.0",
"chalk": "^2.4.1",
Expand All @@ -39,7 +38,7 @@
"gulp": "github:gulpjs/gulp#4.0",
"gulp-babel": "^8.0.0",
"gulp-newer": "^1.4.0",
"jest-cli": "^23.6.0",
"jest-cli": "^24.9.0",
"lerna": "^3.4.0",
"lerna-changelog": "^0.8.0",
"lint-staged": "^7.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function foo(props) {
let bar = "width" in props;
let bar = ("width" in props);
delete props.width;

if (bar) {
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (let i = 0; i < 0; i++) {
var i = 0;
{ let i = 0 };
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
for (let i = 0; i < 0; i++) {
var i = 0;
{
let i = 0;
}
;
}
6 changes: 3 additions & 3 deletions packages/babel-preset-minify/__tests__/minify-env-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ describe("preset along with env", () => {
`,
`
function foo() {
var b = console;
var a = console;
return {
a: function d(c) {
b.log(c);
a: function a(b) {
a.log(b);
}
};
}
Expand Down
3,799 changes: 1,742 additions & 2,057 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit f051377

Please sign in to comment.