allow constant properties to be modified - fixes #131
This commit is contained in:
@@ -17,10 +17,14 @@ exports.ForStatement = function (node, parent, file) {
|
||||
});
|
||||
};
|
||||
|
||||
var getIds = function (node) {
|
||||
return t.getIds(node, false, ["MemberExpression"]);
|
||||
};
|
||||
|
||||
_.each(node.body, function (child) {
|
||||
if (child && t.isVariableDeclaration(child, { kind: "const" })) {
|
||||
_.each(child.declarations, function (declar) {
|
||||
_.each(t.getIds(declar), function (name) {
|
||||
_.each(getIds(declar), function (name) {
|
||||
check(declar, [name]);
|
||||
constants.push(name);
|
||||
});
|
||||
@@ -39,7 +43,7 @@ exports.ForStatement = function (node, parent, file) {
|
||||
if (child._ignoreConstant) return;
|
||||
|
||||
if (t.isVariableDeclarator(child) || t.isDeclaration(child) || t.isAssignmentExpression(child)) {
|
||||
check(child, t.getIds(child));
|
||||
check(child, getIds(child));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -156,13 +156,16 @@ t.toBlock = function (node, parent) {
|
||||
return t.blockStatement(node);
|
||||
};
|
||||
|
||||
t.getIds = function (node, map) {
|
||||
t.getIds = function (node, map, ignoreTypes) {
|
||||
ignoreTypes = ignoreTypes || [];
|
||||
|
||||
var search = [node];
|
||||
var ids = {};
|
||||
|
||||
while (search.length) {
|
||||
var id = search.shift();
|
||||
if (!id) continue;
|
||||
if (_.contains(ignoreTypes, id.type)) continue;
|
||||
|
||||
var nodeKey = t.getIds.nodes[id.type];
|
||||
var arrKey = t.getIds.arrays[id.type];
|
||||
|
||||
Reference in New Issue
Block a user