Re-enable the max-len ESLint rule. (#5265)

This commit is contained in:
Logan Smyth
2017-02-04 08:07:15 -08:00
committed by Henry Zhu
parent 4d411ef83e
commit b845f2b69d
63 changed files with 317 additions and 223 deletions

View File

@@ -33,7 +33,8 @@ describe("evaluation", function () {
it("should bail out on recursive evaluation", function () {
assert.strictEqual(
getPath("function fn(a) { var g = a ? 1 : 2, a = g * this.foo; }").get("body.0.body.body.0.declarations.1.init").evaluate().confident,
getPath("function fn(a) { var g = a ? 1 : 2, a = g * this.foo; }")
.get("body.0.body.body.0.declarations.1.init").evaluate().confident,
false
);
});
@@ -54,7 +55,8 @@ describe("evaluation", function () {
it("should deopt when var is redeclared in the same scope", function () {
assert.strictEqual(
getPath("var x = 2; var y = x + 2; { var x = 3 }").get("body.1.declarations.0.init").evaluate().confident,
getPath("var x = 2; var y = x + 2; { var x = 3 }")
.get("body.1.declarations.0.init").evaluate().confident,
false
);
});
@@ -73,7 +75,8 @@ describe("evaluation", function () {
it("it should not deopt let/const inside blocks", function () {
assert.strictEqual(
getPath("let x = 5; { let x = 1; } let y = x + 5").get("body.2.declarations.0.init").evaluate().value,
getPath("let x = 5; { let x = 1; } let y = x + 5")
.get("body.2.declarations.0.init").evaluate().value,
10
);
const constExample = "const d = true; if (d && true || false) { const d = false; d && 5; }";

View File

@@ -36,7 +36,8 @@ describe("inference", function () {
});
it("it should bail when type changes", function () {
const path = getPath("var x = 1; if (foo) x = null;else x = 3; x === 2").get("body")[2].get("expression");
const path = getPath("var x = 1; if (foo) x = null;else x = 3; x === 2")
.get("body")[2].get("expression");
const left = path.get("left");
const right = path.get("right");
@@ -144,7 +145,8 @@ describe("inference", function () {
it("should infer call return type using async generator function", function () {
const path = getPath("(async function * (): string {})()").get("body")[0].get("expression");
const type = path.getTypeAnnotation();
assert.ok(t.isGenericTypeAnnotation(type) && type.id.name === "AsyncIterator", "should be AsyncIterator");
assert.ok(t.isGenericTypeAnnotation(type) && type.id.name === "AsyncIterator",
"should be AsyncIterator");
});
it("should infer number from x/y", function () {
const path = getPath("x/y").get("body")[0].get("expression");

View File

@@ -17,22 +17,29 @@ function getPath(code) {
describe("scope", function () {
describe("binding paths", function () {
it("function declaration id", function () {
assert.ok(getPath("function foo() {}").scope.getBinding("foo").path.type === "FunctionDeclaration");
assert.ok(getPath("function foo() {}")
.scope.getBinding("foo").path.type === "FunctionDeclaration");
});
it("function expression id", function () {
assert.ok(getPath("(function foo() {})").get("body")[0].get("expression").scope.getBinding("foo").path.type === "FunctionExpression");
assert.ok(getPath("(function foo() {})").get("body")[0].get("expression")
.scope.getBinding("foo").path.type === "FunctionExpression");
});
it("function param", function () {
assert.ok(getPath("(function (foo) {})").get("body")[0].get("expression").scope.getBinding("foo").path.type === "Identifier");
assert.ok(getPath("(function (foo) {})").get("body")[0].get("expression")
.scope.getBinding("foo").path.type === "Identifier");
});
it("variable declaration", function () {
assert.ok(getPath("var foo = null;").scope.getBinding("foo").path.type === "VariableDeclarator");
assert.ok(getPath("var { foo } = null;").scope.getBinding("foo").path.type === "VariableDeclarator");
assert.ok(getPath("var [ foo ] = null;").scope.getBinding("foo").path.type === "VariableDeclarator");
assert.ok(getPath("var { bar: [ foo ] } = null;").scope.getBinding("foo").path.type === "VariableDeclarator");
assert.ok(getPath("var foo = null;")
.scope.getBinding("foo").path.type === "VariableDeclarator");
assert.ok(getPath("var { foo } = null;")
.scope.getBinding("foo").path.type === "VariableDeclarator");
assert.ok(getPath("var [ foo ] = null;")
.scope.getBinding("foo").path.type === "VariableDeclarator");
assert.ok(getPath("var { bar: [ foo ] } = null;")
.scope.getBinding("foo").path.type === "VariableDeclarator");
});
it("purity", function () {

View File

@@ -31,7 +31,8 @@ describe("traverse", function () {
it("traverse", function () {
const expect = [
body[0], body[0].declarations[0], body[0].declarations[0].id, body[0].declarations[0].init,
body[1], body[1].expression, body[1].expression.left, body[1].expression.left.object, body[1].expression.left.property, body[1].expression.right
body[1], body[1].expression, body[1].expression.left, body[1].expression.left.object,
body[1].expression.left.property, body[1].expression.right
];
const actual = [];