diff --git a/lib/6to5/transformation/modules/_default.js b/lib/6to5/transformation/modules/_default.js index 924ab1cb15..c1305df2a9 100644 --- a/lib/6to5/transformation/modules/_default.js +++ b/lib/6to5/transformation/modules/_default.js @@ -138,7 +138,7 @@ DefaultFormatter.prototype.exportDeclaration = function (node, nodes) { }); var newDeclar = t.variableDeclaration(declar.kind, [decl]); - if (i == 0) t.inherits(newDeclar, declar); + if (i === 0) t.inherits(newDeclar, declar); nodes.push(newDeclar); } } else { diff --git a/lib/6to5/transformation/transformers/_declarations.js b/lib/6to5/transformation/transformers/_declarations.js index 3ceee04780..a5eb107e41 100644 --- a/lib/6to5/transformation/transformers/_declarations.js +++ b/lib/6to5/transformation/transformers/_declarations.js @@ -3,11 +3,12 @@ var t = require("../../types"); exports.BlockStatement = exports.Program = function (node) { var kinds = {}; + var kind; for (var i in node._declarations) { var declar = node._declarations[i]; - var kind = declar.kind || "var"; + kind = declar.kind || "var"; var declarNode = t.variableDeclarator(declar.id, declar.init); if (!declar.init) { @@ -18,7 +19,7 @@ exports.Program = function (node) { } } - for (var kind in kinds) { + for (kind in kinds) { node.body.unshift(t.variableDeclaration(kind, kinds[kind])); } }; diff --git a/lib/6to5/transformation/transformers/es6-default-parameters.js b/lib/6to5/transformation/transformers/es6-default-parameters.js index 69fa62755d..93b0ef284c 100644 --- a/lib/6to5/transformation/transformers/es6-default-parameters.js +++ b/lib/6to5/transformation/transformers/es6-default-parameters.js @@ -1,5 +1,4 @@ var traverse = require("../../traverse"); -var Scope = require("../../traverse/scope"); var util = require("../../util"); var t = require("../../types"); var _ = require("lodash"); @@ -13,9 +12,11 @@ exports.Function = function (node, parent, file, scope) { }); var iife = false; + var i; + var def; - for (var i in node.defaults) { - var def = node.defaults[i]; + for (i in node.defaults) { + def = node.defaults[i]; if (!def) continue; var param = node.params[i]; @@ -48,8 +49,8 @@ exports.Function = function (node, parent, file, scope) { var body = []; - for (var i in node.defaults) { - var def = node.defaults[i]; + for (i in node.defaults) { + def = node.defaults[i]; if (!def) continue; body.push(util.template("if-undefined-set-to", { diff --git a/lib/6to5/transformation/transformers/es6-destructuring.js b/lib/6to5/transformation/transformers/es6-destructuring.js index 7353760ea0..bb563bcb34 100644 --- a/lib/6to5/transformation/transformers/es6-destructuring.js +++ b/lib/6to5/transformation/transformers/es6-destructuring.js @@ -220,10 +220,12 @@ exports.VariableDeclaration = function (node, parent, file, scope) { if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return; var nodes = []; + var i; + var declar; var hasPattern = false; - for (var i in node.declarations) { - var declar = node.declarations[i]; + for (i in node.declarations) { + declar = node.declarations[i]; if (t.isPattern(declar.id)) { hasPattern = true; break; @@ -231,8 +233,8 @@ exports.VariableDeclaration = function (node, parent, file, scope) { } if (!hasPattern) return; - for (var i in node.declarations) { - var declar = node.declarations[i]; + for (i in node.declarations) { + declar = node.declarations[i]; var patternId = declar.init; var pattern = declar.id; @@ -252,10 +254,9 @@ exports.VariableDeclaration = function (node, parent, file, scope) { } if (!t.isProgram(parent) && !t.isBlockStatement(parent)) { - var declar; - for (var i in nodes) { - var node = nodes[i]; + for (i in nodes) { + node = nodes[i]; declar = declar || t.variableDeclaration(node.kind, []); if (!t.isVariableDeclaration(node) && declar.kind !== node.kind) { diff --git a/lib/6to5/transformation/transformers/es6-let-scoping.js b/lib/6to5/transformation/transformers/es6-let-scoping.js index bfcd1e6e78..625159fce6 100644 --- a/lib/6to5/transformation/transformers/es6-let-scoping.js +++ b/lib/6to5/transformation/transformers/es6-let-scoping.js @@ -164,7 +164,6 @@ LetScoping.prototype.noClosure = function () { LetScoping.prototype.remap = function () { var replacements = this.info.duplicates; var block = this.block; - var file = this.file; if (!this.info.hasDuplicates) return; @@ -232,8 +231,11 @@ LetScoping.prototype.getInfo = function () { } }; - for (var i in opts.declarators) { - var declar = opts.declarators[i]; + var i; + var declar; + + for (i in opts.declarators) { + declar = opts.declarators[i]; opts.declarators.push(declar); var keys = t.getIds(declar, true); @@ -244,8 +246,8 @@ LetScoping.prototype.getInfo = function () { opts.keys = opts.keys.concat(keys); } - for (var i in block.body) { - var declar = block.body[i]; + for (i in block.body) { + declar = block.body[i]; if (!isLet(declar, block)) continue; _.each(t.getIds(declar, true), function (id, key) { diff --git a/lib/6to5/transformation/transformers/es6-template-literals.js b/lib/6to5/transformation/transformers/es6-template-literals.js index dd29d7a0f5..5a5f4ce445 100644 --- a/lib/6to5/transformation/transformers/es6-template-literals.js +++ b/lib/6to5/transformation/transformers/es6-template-literals.js @@ -29,8 +29,9 @@ exports.TaggedTemplateExpression = function (node, parent, file) { exports.TemplateLiteral = function (node) { var nodes = []; + var i; - for (var i in node.quasis) { + for (i in node.quasis) { var elem = node.quasis[i]; nodes.push(t.literal(elem.value.cooked)); @@ -46,7 +47,7 @@ exports.TemplateLiteral = function (node) { var root = buildBinaryExpression(nodes.shift(), nodes.shift()); - for (var i in nodes) { + for (i in nodes) { root = buildBinaryExpression(root, nodes[i]); } diff --git a/lib/6to5/transformation/transformers/es7-object-spread.js b/lib/6to5/transformation/transformers/es7-object-spread.js index 32cd606ef2..ec10d971c5 100644 --- a/lib/6to5/transformation/transformers/es7-object-spread.js +++ b/lib/6to5/transformation/transformers/es7-object-spread.js @@ -4,8 +4,10 @@ var t = require("../../types"); exports.ObjectExpression = function (node) { var hasSpread = false; - for (var i in node.properties) { - var prop = node.properties[i]; + var i; + var prop; + for (i in node.properties) { + prop = node.properties[i]; if (t.isSpreadProperty(prop)) { hasSpread = true; break; @@ -22,8 +24,8 @@ exports.ObjectExpression = function (node) { props = []; }; - for (var i in node.properties) { - var prop = node.properties[i]; + for (i in node.properties) { + prop = node.properties[i]; if (t.isSpreadProperty(prop)) { push(); args.push(prop.argument); diff --git a/lib/6to5/transformation/transformers/react.js b/lib/6to5/transformation/transformers/react.js index 51fb6f9b8e..3fe950a5ed 100644 --- a/lib/6to5/transformation/transformers/react.js +++ b/lib/6to5/transformation/transformers/react.js @@ -104,18 +104,19 @@ exports.XJSOpeningElement = { exports.XJSElement = { exit: function (node) { var callExpr = node.openingElement; + var i; - for (var i in node.children) { + for (i in node.children) { var child = node.children[i]; if (t.isLiteral(child)) { var lines = child.value.split(/\r\n|\n|\r/); - for (var i in lines) { + for (i in lines) { var line = lines[i]; - var isFirstLine = i == 0; - var isLastLine = i == lines.length - 1; + var isFirstLine = i === 0; + var isLastLine = i === lines.length - 1; // replace rendered whitespace tabs with spaces var trimmedLine = line.replace(/\t/g, ' '); @@ -175,7 +176,7 @@ var addDisplayName = function (id, call) { var safe = true; for (var i in props) { - var prop = props[i]; + prop = props[i]; if (t.isIdentifier(prop.key, { name: "displayName" })) { safe = false; break;