update acorn-to-esprima, add tests for babel/babel-eslint#216

This commit is contained in:
Henry Zhu 2015-11-28 16:31:13 -05:00
parent f76be581b3
commit 4249dcd353
3 changed files with 80 additions and 64 deletions

View File

@ -414,13 +414,13 @@ exports.parseNoPatch = function (code) {
ast.tokens.pop();
// convert tokens
ast.tokens = acornToEsprima.toTokens(ast.tokens, tt);
ast.tokens = acornToEsprima.toTokens(ast.tokens, tt, code);
// add comments
acornToEsprima.convertComments(ast.comments);
// transform esprima and acorn divergent nodes
acornToEsprima.toAST(ast, traverse);
acornToEsprima.toAST(ast, traverse, code);
// ast.program.tokens = ast.tokens;
// ast.program.comments = ast.comments;

View File

@ -330,6 +330,7 @@ describe("acorn-to-esprima", function () {
].join("\n"));
});
describe("babel 6 tests", function () {
it("MethodDefinition", function () {
parseAndAssertSame([
"export default class A {",
@ -402,4 +403,11 @@ describe("acorn-to-esprima", function () {
it("super outside method", function () {
parseAndAssertSame("function F() { super(); }");
});
it("StringLiteral", function () {
parseAndAssertSame('');
parseAndAssertSame("");
parseAndAssertSame("a");
});
});
});

View File

@ -1296,4 +1296,12 @@ describe("verify", function () {
[ "1:13 \"x\" was used before it was defined no-use-before-define" ]
)
});
it("jsx and stringliteral #216", function () {
verifyAndAssertMessages(
"<div className=''></div>",
{},
[]
)
});
});