Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Recognized optional chaining operator as Punctuator token
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed Jun 14, 2018
1 parent c31567e commit e15ce52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/babylon-to-espree/toToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = function(token, tt, source) {
type === tt.incDec ||
type === tt.colon ||
type === tt.question ||
type === tt.questionDot ||
type === tt.template ||
type === tt.backQuote ||
type === tt.dollarBraceL ||
Expand Down
10 changes: 10 additions & 0 deletions test/babel-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ describe("babylon-to-espree", () => {
parseAndAssertSame("export { foo as bar };");
});

// Espree doesn't support the optional chaining operator yet
it("optional chaining operator (token)", () => {
const code = "foo?.bar";
var babylonAST = babelEslint.parseForESLint(code, {
eslintVisitorKeys: true,
eslintScopeManager: true,
}).ast;
assert.strictEqual(babylonAST.tokens[1].type, "Punctuator");
});

// Espree doesn't support the nullish coalescing operator yet
it("nullish coalescing operator (token)", () => {
const code = "foo ?? bar";
Expand Down

0 comments on commit e15ce52

Please sign in to comment.