diff --git a/bin/6to5/file.js b/bin/6to5/file.js index 1afc7587a2..f59eb6d978 100644 --- a/bin/6to5/file.js +++ b/bin/6to5/file.js @@ -6,7 +6,7 @@ var util = require("./util"); var fs = require("fs"); var _ = require("lodash"); -module.exports = function (commander, filenames, opts) { +module.exports = function (commander, filenames) { var results = []; var buildResult = function () { @@ -48,7 +48,7 @@ module.exports = function (commander, filenames, opts) { return { map: map, code: code - } + }; }; var output = function () { @@ -101,7 +101,7 @@ module.exports = function (commander, filenames, opts) { }); _.each(_filenames, function (filename, i) { - results.push(util.compile(filename, { _noStrict: i != 0 })); + results.push(util.compile(filename, { _noStrict: +i !== 0 })); }); output(); diff --git a/bin/6to5/index.js b/bin/6to5/index.js index 5500ff96fd..970dd331f2 100755 --- a/bin/6to5/index.js +++ b/bin/6to5/index.js @@ -1,13 +1,8 @@ #!/usr/bin/env node var commander = require("commander"); -var sourceMap = require("source-map"); var transform = require("../../lib/6to5/transform"); -var chokidar = require("chokidar"); -var mkdirp = require("mkdirp"); -var util2 = require("../../lib/6to5/util"); -var util = require("./util"); -var path = require("path"); +var util = require("../../lib/6to5/util"); var fs = require("fs"); var _ = require("lodash"); @@ -17,8 +12,8 @@ commander.option("-f, --filename [filename]", "Filename to use when reading from commander.option("-w, --watch", "Recompile files on changes"); commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common"); -commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util2.list); -commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util2.list); +commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list); +commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list); commander.option("-o, --out-file [out]", "Compile all input files into a single file"); commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory"); diff --git a/lib/6to5/generator.js b/lib/6to5/generator.js index 3b303bc47b..d5dcd5031e 100644 --- a/lib/6to5/generator.js +++ b/lib/6to5/generator.js @@ -21,6 +21,7 @@ CodeGenerator.prototype.generate = function (ast, opts) { CodeGenerator.prototype.buildPrint = function (parent) { var self = this; + var print = function (node) { return self.print(node, parent); }; @@ -138,7 +139,6 @@ CodeGenerator.prototype.ArrowFunctionExpression = function (node, print) { CodeGenerator.prototype.MethodDefinition = function (node, print) { throw new Error("MethodDefinition"); - return; }; CodeGenerator.prototype.YieldExpression = function (node, print) { @@ -189,7 +189,7 @@ CodeGenerator.prototype.BlockStatement = function (node, print) { if (body.length === 0) { return "{}"; } else { - return "{\n" + this.indent(print.sequence(body)) + "\n}" + return "{\n" + this.indent(print.sequence(body)) + "\n}"; } }; @@ -223,7 +223,6 @@ CodeGenerator.prototype.ObjectExpression = CodeGenerator.prototype.ObjectPattern = function (node, print) { var allowBreak = false; var indent = this.indent; - var print = this.buildPrint(node); var parts = [len > 0 ? "{\n" : "{"]; var len = node.properties.length; @@ -267,7 +266,6 @@ CodeGenerator.prototype.ArrayExpression = CodeGenerator.prototype.ArrayPattern = function (node, print) { var elems = node.elements; var parts = ["["]; - var print = this.buildPrint(node); var len = elems.length; _.each(elems, function(elem, i) { @@ -358,7 +356,6 @@ CodeGenerator.prototype.NewExpression = function (node, print) { }; CodeGenerator.prototype.VariableDeclaration = function (node, print, parent) { - var print = print; var code = node.kind + " "; var maxLen = 0; @@ -371,6 +368,7 @@ CodeGenerator.prototype.VariableDeclaration = function (node, print, parent) { switch (maxLen) { case 0: code += printed[0]; + break; default: code += printed.join(",\n "); @@ -410,7 +408,7 @@ CodeGenerator.prototype.ForStatement = function (node, print) { var code = "for ("; code += print(node.init) + "; "; code += print(node.test) + "; "; - code += print(node.update) + code += print(node.update); code += ") "; code += print(node.body); return code; @@ -559,7 +557,7 @@ CodeGenerator.prototype._method = function (kind, key, value, print) { ); return parts.join(""); -} +}; CodeGenerator.prototype.MethodDefinition = function (node, print) { var parts = [];