Skip to content

Commit

Permalink
Fix: wrong token type of ! and ~ (fixes babel#576) (babel#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea authored Jan 17, 2018
1 parent bf27f60 commit 236adb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/babylon-to-espree/toToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module.exports = function(token, tt, source) {
type === tt.plusMin ||
type === tt.modulo ||
type === tt.exponent ||
type === tt.prefix ||
type === tt.bang ||
type === tt.tilde ||
type === tt.doubleColon ||
type.isAssign
) {
Expand Down
14 changes: 8 additions & 6 deletions test/babel-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ function parseAndAssertSame(code) {
assertImplementsAST(esAST, babylonAST);
} catch (err) {
var traversal = err.message.slice(3, err.message.indexOf(":"));
if (esAST.tokens) {
delete esAST.tokens;
}
if (babylonAST.tokens) {
delete babylonAST.tokens;
}
err.message += unpad(`
espree:
${util.inspect(lookup(esAST, traversal, 2), {
Expand Down Expand Up @@ -170,6 +164,14 @@ describe("babylon-to-espree", () => {
parseAndAssertSame("a = 1");
});

it("logical NOT", () => {
parseAndAssertSame("!0");
});

it("bitwise NOT", () => {
parseAndAssertSame("~0");
});

it("class declaration", () => {
parseAndAssertSame("class Foo {}");
});
Expand Down

0 comments on commit 236adb8

Please sign in to comment.