Fix to convert hash token. (babel/babel-eslint#753)

This commit is contained in:
Yosuke Ota 2019-02-15 07:56:30 +09:00
parent 025fff7871
commit 3fcfc90a12
2 changed files with 12 additions and 0 deletions

View File

@ -44,6 +44,7 @@ module.exports = function(token, tt, source) {
type === tt.bang || type === tt.bang ||
type === tt.tilde || type === tt.tilde ||
type === tt.doubleColon || type === tt.doubleColon ||
type === tt.hash ||
type.isAssign type.isAssign
) { ) {
token.type = "Punctuator"; token.type = "Punctuator";

View File

@ -267,6 +267,17 @@ describe("babylon-to-espree", () => {
assert.strictEqual(babylonAST.tokens[1].type, "Punctuator"); assert.strictEqual(babylonAST.tokens[1].type, "Punctuator");
}); });
// Espree doesn't support the private fields yet
it("hash (token)", () => {
const code = "class A { #x }";
const babylonAST = babelEslint.parseForESLint(code, {
eslintVisitorKeys: true,
eslintScopeManager: true,
}).ast;
assert.strictEqual(babylonAST.tokens[3].type, "Punctuator");
assert.strictEqual(babylonAST.tokens[3].value, "#");
});
it.skip("empty program with line comment", () => { it.skip("empty program with line comment", () => {
parseAndAssertSame("// single comment"); parseAndAssertSame("// single comment");
}); });