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:
parent
c15a7c6b65
commit
adc009b832
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 },
|
||||
[]
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user