fix linting errors

This commit is contained in:
Sebastian McKenzie 2015-02-18 13:14:06 +11:00
parent 067047da34
commit 692262df1b

View File

@ -1,53 +1,53 @@
"use strict"; "use strict";
var t = require("../../../types"); var util = require("../../../util");
var util = require("../../../util"); var t = require("../../../types");
var propertyFunctionVisitor = { var propertyFunctionVisitor = {
enter: function (node, parent, scope, state, file) { enter: function (node, parent, scope, state) {
if (t.isReferencedIdentifier(node, parent, { name: state.name }) && scope.getBindingIdentifier(node.name) === state.binding) { if (t.isReferencedIdentifier(node, parent, { name: state.name }) && scope.getBindingIdentifier(node.name) === state.binding) {
return state.getOuter(); return state.getOuter();
} }
} }
}; };
exports.FunctionExpression = function (node, parent, scope, file) { exports.FunctionExpression = function (node, parent, scope, file) {
if (node.id) return; if (node.id) return;
var id; var id;
if (t.isProperty(parent)) { if (t.isProperty(parent)) {
id = parent.key; id = parent.key;
} else if (t.isVariableDeclarator(parent)) { } else if (t.isVariableDeclarator(parent)) {
id = parent.id; id = parent.id;
} else { } else {
return; return;
} }
var binding = scope.getBindingIdentifier(id.name); var binding = scope.getBindingIdentifier(id.name);
var outerId, selfGlobalId; var outerId, selfGlobalId;
scope.traverse(node, propertyFunctionVisitor, { scope.traverse(node, propertyFunctionVisitor, {
name: id.name, name: id.name,
binding: binding, binding: binding,
getOuter: function () { getOuter: function () {
if (!binding) { if (!binding) {
return t.memberExpression( return t.memberExpression(
selfGlobalId || (selfGlobalId = file.addHelper("self-global")), selfGlobalId || (selfGlobalId = file.addHelper("self-global")),
id id
); );
} }
return t.callExpression( return t.callExpression(
outerId || (outerId = scope.generateUidIdentifier("getOuter")), outerId || (outerId = scope.generateUidIdentifier("getOuter")),
[] []
); );
} }
}); });
node.id = id; node.id = id;
if (outerId) { if (outerId) {
return util.template("named-func", { return util.template("named-func", {
GET_OUTER_ID: outerId, GET_OUTER_ID: outerId,
ID: id, ID: id,
FUNCTION: node FUNCTION: node
}); });
} }
}; };
exports.optional = true; exports.optional = true;