fix jsHint errors in branch 2.0.0

This commit is contained in:
chico
2014-12-23 06:15:50 +03:00
parent 694a8dc456
commit 5de9c22452
8 changed files with 40 additions and 31 deletions

View File

@@ -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 {

View File

@@ -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]));
}
};

View File

@@ -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", {

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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]);
}

View File

@@ -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);

View File

@@ -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;