Merge pull request babel/babel-eslint#121 from hzoo/i-120
don't visit var decl - fixes babel/babel-eslint#120
This commit is contained in:
parent
8d3a7244c3
commit
84a8d342f2
@ -232,7 +232,10 @@ function monkeypatch() {
|
|||||||
referencer.prototype.VariableDeclaration = function(node) {
|
referencer.prototype.VariableDeclaration = function(node) {
|
||||||
if (node.declarations) {
|
if (node.declarations) {
|
||||||
for (var i = 0; i < node.declarations.length; i++) {
|
for (var i = 0; i < node.declarations.length; i++) {
|
||||||
checkIdentifierOrVisit.call(this, node.declarations[i].id);
|
var type = node.declarations[i].id.typeAnnotation;
|
||||||
|
if (type) {
|
||||||
|
checkIdentifierOrVisit.call(this, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
variableDeclaration.call(this, node);
|
variableDeclaration.call(this, node);
|
||||||
|
|||||||
@ -950,7 +950,7 @@ describe("verify", function () {
|
|||||||
it("array #9", function () {
|
it("array #9", function () {
|
||||||
verifyAndAssertMessages([
|
verifyAndAssertMessages([
|
||||||
"let arr = [1, 2, 3];",
|
"let arr = [1, 2, 3];",
|
||||||
"let b = [for (e of arr) String(e)];"
|
"let b = [for (e of arr) String(e)]; b;"
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||||
[]
|
[]
|
||||||
@ -1082,4 +1082,12 @@ describe("verify", function () {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("detects minimal no-unused-vars case #120", function () {
|
||||||
|
verifyAndAssertMessages(
|
||||||
|
"var unused;",
|
||||||
|
{ "no-unused-vars": 1 },
|
||||||
|
[ "1:4 unused is defined but never used no-unused-vars" ]
|
||||||
|
)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user