Merge pull request babel/babel-eslint#122 from hzoo/i-95

visit properties in ObjectPattern - fixes babel/babel-eslint#95
This commit is contained in:
Henry Zhu 2015-06-06 16:54:05 -04:00
parent c15a7c6b65
commit adc009b832
2 changed files with 17 additions and 3 deletions

View File

@ -231,9 +231,15 @@ function monkeypatch() {
referencer.prototype.VariableDeclaration = function(node) {
if (node.declarations) {
for (var i = 0; i < node.declarations.length; i++) {
var type = node.declarations[i].id.typeAnnotation;
if (type) {
checkIdentifierOrVisit.call(this, type);
var id = node.declarations[i].id;
var typeAnnotation = id.typeAnnotation;
if (typeAnnotation) {
checkIdentifierOrVisit.call(this, typeAnnotation);
}
if (id.type === 'ObjectPattern') {
for (var j = 0; j < id.properties.length; j++) {
this.visit(id.properties[j]);
}
}
}
}

View File

@ -1090,4 +1090,12 @@ describe("verify", function () {
[ "1:4 unused is defined but never used no-unused-vars" ]
);
});
it("visits excluded properties left of spread #95", function () {
verifyAndAssertMessages(
"var originalObject = {}; var {field1, field2, ...clone} = originalObject;",
{ "no-undef": 1, "no-unused-vars": 1 },
[]
)
});
});