babel-eslint
Advanced tools
Comparing version 3.1.10 to 3.1.11
49
index.js
@@ -166,2 +166,6 @@ var acornToEsprima = require("./acorn-to-esprima"); | ||
} else if (node.type === "Identifier") { | ||
// exception for polymorphic types: <T>, <A>, etc | ||
if (node.name.length === 1 && node.name === node.name.toUpperCase()) { | ||
return; | ||
} | ||
this.visit(node); | ||
@@ -177,6 +181,2 @@ } else { | ||
visitDecorators.call(this, node); | ||
// visit class | ||
if (node.id) { | ||
this.visit(node.id); | ||
} | ||
// visit flow type: ClassImplements | ||
@@ -203,3 +203,3 @@ if (node.implements) { | ||
referencer.prototype.visitProperty = function(node) { | ||
if (node.value.type === 'TypeCastExpression') { | ||
if (node.value.type === "TypeCastExpression") { | ||
visitTypeAnnotation.call(this, node.value); | ||
@@ -244,14 +244,17 @@ } | ||
referencer.prototype.TypeAlias = function(node) { | ||
this.currentScope().__define( | ||
node.id, | ||
function createScopeVariable (node, name) { | ||
this.currentScope().variableScope.__define(name, | ||
new Definition( | ||
"Variable", | ||
node.id, | ||
node, | ||
null, | ||
null, | ||
null | ||
"Variable", | ||
name, | ||
node, | ||
null, | ||
null, | ||
null | ||
) | ||
); | ||
} | ||
referencer.prototype.TypeAlias = function(node) { | ||
createScopeVariable.call(this, node, node.id); | ||
if (node.right) { | ||
@@ -266,2 +269,20 @@ visitTypeAnnotation.call(this, node.right); | ||
} | ||
referencer.prototype.ComprehensionBlock = function(node) { | ||
var left = node.left; | ||
if (left) { | ||
if (left.type === "Identifier") { | ||
createScopeVariable.call(this, node, left); | ||
} else if (left.type === "ArrayPattern") { | ||
for (var i = 0; i < left.elements.length; i++) { | ||
if (left.elements[i]) { | ||
createScopeVariable.call(this, left.elements, left.elements[i]); | ||
} | ||
} | ||
} | ||
} | ||
if (node.right) { | ||
this.visit(node.right); | ||
} | ||
} | ||
} | ||
@@ -268,0 +289,0 @@ |
{ | ||
"name": "babel-eslint", | ||
"version": "3.1.10", | ||
"version": "3.1.11", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -258,5 +258,4 @@ /*eslint-env mocha*/ | ||
verifyAndAssertMessages([ | ||
"import type Foo from 'foo';", | ||
"import type Bar from 'foo';", | ||
"class Foo implements Bar {}" | ||
"export default class Foo implements Bar {}" | ||
].join("\n"), | ||
@@ -301,2 +300,22 @@ { "no-unused-vars": 1, "no-undef": 1 }, | ||
it("polymorphpic types #109", function () { | ||
verifyAndAssertMessages([ | ||
"export default function groupByEveryN<T>(array: Array<T>, n: number): Array<Array<?T>> {}" | ||
].join("\n"), | ||
{ "no-unused-vars": 1, "no-undef": 1 }, | ||
[] | ||
); | ||
}); | ||
it("types definition from import", function () { | ||
verifyAndAssertMessages([ | ||
"import type Promise from 'bluebird';", | ||
"type Operation = () => Promise;", | ||
"x: Operation;" | ||
].join("\n"), | ||
{ "no-unused-vars": 1, "no-undef": 1 }, | ||
[] | ||
); | ||
}); | ||
it("1", function () { | ||
@@ -464,3 +483,3 @@ verifyAndAssertMessages( | ||
"import type Foo2 from 'foo';", | ||
"class Bar {set fooProp(value:Foo):Foo2{ value; }}" | ||
"export default class Bar {set fooProp(value:Foo):Foo2{ value; }}" | ||
].join("\n"), | ||
@@ -475,4 +494,4 @@ { "no-unused-vars": 1, "no-undef": 1 }, | ||
[ | ||
"import type Foo from 'foo';", | ||
"class Foo {get fooProp():Foo{}}" | ||
"import type Foo2 from 'foo';", | ||
"export default class Foo {get fooProp(): Foo2{}}" | ||
].join("\n"), | ||
@@ -588,3 +607,3 @@ { "no-unused-vars": 1, "no-undef": 1 }, | ||
"import Baz from 'foo';", | ||
"class Bar<Foo> extends Baz<Foo2> { };" | ||
"export default class Bar<Foo> extends Baz<Foo2> { };" | ||
].join("\n"), | ||
@@ -602,3 +621,3 @@ { "no-unused-vars": 1, "no-undef": 1 }, | ||
"import type Foo3 from 'foo';", | ||
"class Bar<Foo> { bar<Foo2>():Foo3 { return 42; }}" | ||
"export default class Bar<Foo> { bar<Foo2>():Foo3 { return 42; }}" | ||
].join("\n"), | ||
@@ -615,3 +634,3 @@ { "no-unused-vars": 1, "no-undef": 1 }, | ||
"import type Foo2 from 'foo';", | ||
"class Bar { static prop1:Foo; prop2:Foo2; }" | ||
"export default class Bar { static prop1:Foo; prop2:Foo2; }" | ||
].join("\n"), | ||
@@ -895,2 +914,15 @@ { "no-unused-vars": 1, "no-undef": 1 }, | ||
it("class definition: gaearon/redux#24", function () { | ||
verifyAndAssertMessages([ | ||
"export default function root(stores) {", | ||
"return DecoratedComponent => class ReduxRootDecorator {", | ||
"a() { DecoratedComponent; }", | ||
"};", | ||
"}", | ||
].join("\n"), | ||
{ "no-undef": 1, "no-unused-vars": 1 }, | ||
[] | ||
); | ||
}); | ||
it("class properties", function () { | ||
@@ -925,2 +957,47 @@ verifyAndAssertMessages( | ||
describe("comprehensions", function () { | ||
it("array #9", function () { | ||
verifyAndAssertMessages([ | ||
"let arr = [1, 2, 3];", | ||
"let b = [for (e of arr) String(e)];" | ||
].join("\n"), | ||
{ "no-unused-vars": 1, "no-undef": 1 }, | ||
[] | ||
); | ||
}); | ||
it("array, if statement, multiple blocks", function () { | ||
verifyAndAssertMessages([ | ||
"let arr = [1, 2, 3];", | ||
"let arr2 = [1, 2, 3];", | ||
"[for (x of arr) for (y of arr2) if (x === true && y === true) x + y];" | ||
].join("\n"), | ||
{ "no-unused-vars": 1, "no-undef": 1 }, | ||
[] | ||
); | ||
}); | ||
it("expression, if statement, multiple blocks", function () { | ||
verifyAndAssertMessages([ | ||
"let arr = [1, 2, 3];", | ||
"let arr2 = [1, 2, 3];", | ||
"(for (x of arr) for (y of arr2) if (x === true && y === true) x + y)" | ||
].join("\n"), | ||
{ "no-unused-vars": 1, "no-undef": 1 }, | ||
[] | ||
); | ||
}); | ||
it("ArrayPattern", function () { | ||
verifyAndAssertMessages([ | ||
"let arr = [1, 2, 3];", | ||
"let arr2 = [1, 2, 3];", | ||
"[for ([,x] of arr) for ({[start.x]: x, [start.y]: y} of arr2) x]" | ||
].join("\n"), | ||
{ "no-unused-vars": 1, "no-undef": 1 }, | ||
[] | ||
); | ||
}); | ||
}); | ||
describe("decorators #72", function () { | ||
@@ -927,0 +1004,0 @@ it("class declaration", function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57914
1804