Repository: Rich-Harris/buble
Pull request #134 (2018-05-14 13:28:15)

fix: move regexpu-core out of devDependencies
Used here:
https://github.com/Rich-Harris/buble/blob/master/src/program/types/Literal.js#L3


Patch:
diff --git a/.eslintrc b/.eslintrc
index 04919df..dc36624 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -10,8 +10,6 @@
     },
     "env": {
         "es6": true,
-        "browser": true,
-        "mocha": true,
         "node": true
     },
     "extends": "eslint:recommended",
diff --git a/bin/runBuble.js b/bin/runBuble.js
index a93c0a9..ab1080a 100644
--- a/bin/runBuble.js
+++ b/bin/runBuble.js
@@ -98,7 +98,7 @@ module.exports = function(command) {
 	};
 
 	if (command.target) {
-		if (!/^(?:(\w+):([\d\.]+),)*(\w+):([\d\.]+)$/.test(command.target)) {
+		if (!/^(?:(\w+):([\d.]+),)*(\w+):([\d.]+)$/.test(command.target)) {
 			handleError({ code: 'BAD_TARGET' });
 		}
 
diff --git a/package.json b/package.json
index 1adf80c..81c1399 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
     "test": "mocha test/test.js",
     "pretest": "npm run build",
     "prepublish": "npm test",
-    "lint": "eslint src"
+    "lint": "eslint bin/ src/ test/test.js"
   },
   "bin": {
     "buble": "./bin/buble"
@@ -51,7 +51,6 @@
     "eslint": "^4.17.0",
     "glob": "^7.0.3",
     "mocha": "^5.0.0",
-    "regexpu-core": "^4.1.3",
     "rimraf": "^2.5.2",
     "rollup": "^0.55.5",
     "rollup-plugin-buble": "^0.19.1",
@@ -69,6 +68,7 @@
     "magic-string": "^0.22.4",
     "minimist": "^1.2.0",
     "os-homedir": "^1.0.1",
+    "regexpu-core": "^4.1.3",
     "vlq": "^1.0.0"
   }
 }
diff --git a/src/program/types/ForInStatement.js b/src/program/types/ForInStatement.js
index 6354c62..45346be 100644
--- a/src/program/types/ForInStatement.js
+++ b/src/program/types/ForInStatement.js
@@ -14,15 +14,9 @@ export default class ForInStatement extends LoopStatement {
 
 		if (this.shouldRewriteAsFunction) {
 			// which variables are declared in the init statement?
-			const names =
-				hasDeclaration
-					? [].concat.apply(
-							[],
-							this.left.declarations.map(declarator =>
-								extractNames(declarator.id)
-							)
-						)
-					: [];
+			const names = hasDeclaration
+				? this.left.declarations.map(declarator => extractNames(declarator.id))
+				: [];
 
 			this.args = names.map(
 				name => (name in this.aliases ? this.aliases[name].outer : name)
diff --git a/src/program/types/ForStatement.js b/src/program/types/ForStatement.js
index 3446ebb..c43ede0 100644
--- a/src/program/types/ForStatement.js
+++ b/src/program/types/ForStatement.js
@@ -13,15 +13,9 @@ export default class ForStatement extends LoopStatement {
 
 		if (this.shouldRewriteAsFunction) {
 			// which variables are declared in the init statement?
-			const names =
-				this.init.type === 'VariableDeclaration'
-					? [].concat.apply(
-							[],
-							this.init.declarations.map(declarator =>
-								extractNames(declarator.id)
-							)
-						)
-					: [];
+			const names = this.init.type === 'VariableDeclaration'
+				? this.init.declarations.map(declarator => extractNames(declarator.id))
+				: [];
 
 			const aliases = this.aliases;
 
diff --git a/src/program/types/JSXOpeningFragment.js b/src/program/types/JSXOpeningFragment.js
index ba3c6eb..78e72d8 100644
--- a/src/program/types/JSXOpeningFragment.js
+++ b/src/program/types/JSXOpeningFragment.js
@@ -1,7 +1,7 @@
 import Node from '../Node.js';
 
 export default class JSXOpeningFragment extends Node {
-	transpile(code, transforms) {
+	transpile(code) {
 		code.overwrite(this.start, this.end, `${this.program.jsx}( React.Fragment, null`);
 	}
 }
diff --git a/src/program/types/VariableDeclaration.js b/src/program/types/VariableDeclaration.js
index 694e1e7..aa5e7ec 100644
--- a/src/program/types/VariableDeclaration.js
+++ b/src/program/types/VariableDeclaration.js
@@ -15,6 +15,7 @@ export default class VariableDeclaration extends Node {
 		if (transforms.letConst && kind !== 'var') {
 			kind = 'var';
 			code.overwrite(this.start, this.start + this.kind.length, kind, {
+				contentOnly: true,
 				storeName: true
 			});
 		}


Test patch:
diff --git a/test/samples/block-scoping.js b/test/samples/block-scoping.js
index 93d2a5a..3600425 100644
--- a/test/samples/block-scoping.js
+++ b/test/samples/block-scoping.js
@@ -536,5 +536,13 @@ module.exports = [
 				var c$1 = prop.end;
 				console.log(c$1);
 			}`,
+	},
+
+	{
+		description: 'emits correct code after block-less if',
+
+		input: 'if(0);const e=0',
+
+		output: 'if(0){ ; }var e=0'
 	}
 ];