update acorn-to-esprima, add tests for babel/babel-eslint#216
This commit is contained in:
parent
f76be581b3
commit
4249dcd353
@ -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;
|
||||
|
||||
@ -330,76 +330,84 @@ describe("acorn-to-esprima", function () {
|
||||
].join("\n"));
|
||||
});
|
||||
|
||||
it("MethodDefinition", function () {
|
||||
parseAndAssertSame([
|
||||
"export default class A {",
|
||||
"a() {}",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
describe("babel 6 tests", function () {
|
||||
it("MethodDefinition", function () {
|
||||
parseAndAssertSame([
|
||||
"export default class A {",
|
||||
"a() {}",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
|
||||
it("MethodDefinition 2", function () {
|
||||
parseAndAssertSame([
|
||||
"export default class Bar { get bar() { return 42; }}"
|
||||
].join("\n"));
|
||||
});
|
||||
it("MethodDefinition 2", function () {
|
||||
parseAndAssertSame([
|
||||
"export default class Bar { get bar() { return 42; }}"
|
||||
].join("\n"));
|
||||
});
|
||||
|
||||
it("ClassMethod", function () {
|
||||
parseAndAssertSame([
|
||||
"class A {",
|
||||
"constructor() {",
|
||||
"}",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
it("ClassMethod", function () {
|
||||
parseAndAssertSame([
|
||||
"class A {",
|
||||
"constructor() {",
|
||||
"}",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
|
||||
it("ClassMethod multiple params", function () {
|
||||
parseAndAssertSame([
|
||||
"class A {",
|
||||
"constructor(a, b, c) {",
|
||||
"}",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
it("ClassMethod multiple params", function () {
|
||||
parseAndAssertSame([
|
||||
"class A {",
|
||||
"constructor(a, b, c) {",
|
||||
"}",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
|
||||
it("ClassMethod multiline", function () {
|
||||
parseAndAssertSame([
|
||||
"class A {",
|
||||
" constructor(",
|
||||
" a,",
|
||||
" b,",
|
||||
" c",
|
||||
" ) {",
|
||||
"",
|
||||
" }",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
it("ClassMethod multiline", function () {
|
||||
parseAndAssertSame([
|
||||
"class A {",
|
||||
" constructor(",
|
||||
" a,",
|
||||
" b,",
|
||||
" c",
|
||||
" ) {",
|
||||
"",
|
||||
" }",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
|
||||
it("ClassMethod oneline", function () {
|
||||
parseAndAssertSame("class A { constructor(a, b, c) {} }");
|
||||
});
|
||||
it("ClassMethod oneline", function () {
|
||||
parseAndAssertSame("class A { constructor(a, b, c) {} }");
|
||||
});
|
||||
|
||||
it("ObjectMethod", function () {
|
||||
parseAndAssertSame([
|
||||
"var a = {",
|
||||
"b(c) {",
|
||||
"}",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
it("ObjectMethod", function () {
|
||||
parseAndAssertSame([
|
||||
"var a = {",
|
||||
"b(c) {",
|
||||
"}",
|
||||
"}"
|
||||
].join("\n"));
|
||||
});
|
||||
|
||||
it("do not allow import export everywhere", function() {
|
||||
assert.throws(function () {
|
||||
parseAndAssertSame("function F() { import a from \"a\"; }");
|
||||
}, /Illegal import declaration/)
|
||||
});
|
||||
it("do not allow import export everywhere", function() {
|
||||
assert.throws(function () {
|
||||
parseAndAssertSame("function F() { import a from \"a\"; }");
|
||||
}, /Illegal import declaration/)
|
||||
});
|
||||
|
||||
it("return outside function", function () {
|
||||
parseAndAssertSame("return;");
|
||||
});
|
||||
it("return outside function", function () {
|
||||
parseAndAssertSame("return;");
|
||||
});
|
||||
|
||||
it("super outside method", function () {
|
||||
parseAndAssertSame("function F() { super(); }");
|
||||
it("super outside method", function () {
|
||||
parseAndAssertSame("function F() { super(); }");
|
||||
});
|
||||
|
||||
it("StringLiteral", function () {
|
||||
parseAndAssertSame('');
|
||||
parseAndAssertSame("");
|
||||
parseAndAssertSame("a");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -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>",
|
||||
{},
|
||||
[]
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user