fix linting errors

This commit is contained in:
Sebastian McKenzie
2015-02-21 12:41:11 +11:00
parent 1effa72a33
commit 74186241f9
3 changed files with 94 additions and 94 deletions

View File

@@ -180,7 +180,7 @@ DestructuringTransformer.prototype.canUnpackArrayPattern = function (pattern, ar
DestructuringTransformer.prototype.pushUnpackedArrayPattern = function (pattern, arr) {
for (var i = 0; i < pattern.elements.length; i++) {
var elem = pattern.elements[i]
var elem = pattern.elements[i];
if (t.isRestElement(elem)) {
this.push(elem.argument, t.arrayExpression(arr.elements.slice(i)));
} else {

View File

@@ -7,7 +7,7 @@ exports.check = function (node) {
return t.isProperty(node) && (node.method || node.shorthand);
};
exports.Property = function (node, parent, scope, file) {
exports.Property = function (node) {
if (node.method) {
node.method = false;
}

View File

@@ -1,92 +1,92 @@
"use strict";
var t = require("../../../types");
var util = require("../../../util");
var propertyFunctionVisitor = {
enter: function (node, parent, scope, state, file) {
if (t.isReferencedIdentifier(node, parent, { name: state.name }) && scope.getBindingIdentifier(node.name) === state.binding) {
return state.getOuter();
}
}
};
//exports.ArrowFunctionExpression =
exports.FunctionExpression = function (node, parent, scope, file) {
// has an `id` so we don't need to infer one
if (node.id) return;
var id;
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
// { foo: function () {} };
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
// var foo = function () {};
id = parent.id;
} else {
return;
}
if (!t.isIdentifier(id)) return;
// check to see if we have a local binding of the id we're setting inside of
// the function, this is important as there are caveats associated
var bindingInfo = scope.getOwnBindingInfo(id.name);
if (bindingInfo) {
if (bindingInfo.type === "param") {
// safari will blow up in strict mode with code like:
//
// var t = function t(t) {};
//
// with the error:
//
// Cannot declare a parameter named 't' as it shadows the name of a
// strict mode function.
//
// this isn't to the spec and they've invented this behaviour which is
// **extremely** annoying so we avoid setting the name if it has a param
// with the same id
} else {
// otherwise it's defined somewhere in scope like:
//
// var t = function () {
// var t = 2;
// };
//
// so we can safely just set the id and move along as it shadows the
// bound function id
node.id = id;
}
return;
}
//
var binding = scope.getBindingIdentifier(id.name);
var outerId, selfGlobalId;
scope.traverse(node, propertyFunctionVisitor, {
name: id.name,
binding: binding,
getOuter: function () {
return t.callExpression(
outerId || (outerId = scope.generateUidIdentifier("getOuter")),
[]
);
}
});
node.id = id;
if (outerId) {
return util.template("named-func", {
GET_OUTER_ID: outerId,
FUNCTION: node,
ID: id
});
}
};
"use strict";
var t = require("../../../types");
var util = require("../../../util");
var propertyFunctionVisitor = {
enter: function (node, parent, scope, state) {
if (t.isReferencedIdentifier(node, parent, { name: state.name }) && scope.getBindingIdentifier(node.name) === state.binding) {
return state.getOuter();
}
}
};
//exports.ArrowFunctionExpression =
exports.FunctionExpression = function (node, parent, scope) {
// has an `id` so we don't need to infer one
if (node.id) return;
var id;
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
// { foo: function () {} };
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
// var foo = function () {};
id = parent.id;
} else {
return;
}
if (!t.isIdentifier(id)) return;
// check to see if we have a local binding of the id we're setting inside of
// the function, this is important as there are caveats associated
var bindingInfo = scope.getOwnBindingInfo(id.name);
if (bindingInfo) {
if (bindingInfo.type === "param") {
// safari will blow up in strict mode with code like:
//
// var t = function t(t) {};
//
// with the error:
//
// Cannot declare a parameter named 't' as it shadows the name of a
// strict mode function.
//
// this isn't to the spec and they've invented this behaviour which is
// **extremely** annoying so we avoid setting the name if it has a param
// with the same id
} else {
// otherwise it's defined somewhere in scope like:
//
// var t = function () {
// var t = 2;
// };
//
// so we can safely just set the id and move along as it shadows the
// bound function id
node.id = id;
}
return;
}
//
var binding = scope.getBindingIdentifier(id.name);
var outerId;
scope.traverse(node, propertyFunctionVisitor, {
name: id.name,
binding: binding,
getOuter: function () {
return t.callExpression(
outerId || (outerId = scope.generateUidIdentifier("getOuter")),
[]
);
}
});
node.id = id;
if (outerId) {
return util.template("named-func", {
GET_OUTER_ID: outerId,
FUNCTION: node,
ID: id
});
}
};