Skip to content

Commit

Permalink
Fix: tokenize the latest right curly brace (fixes eslint#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
finico authored and finico committed Aug 14, 2019
1 parent f5e58cc commit 8ba174d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ module.exports = () => Parser => class Espree extends Parser {
this.next();
} while (this.type !== tokTypes.eof);

// Consume the final eof token
this.next();

const extra = this[STATE];
const tokens = extra.tokens;

Expand Down
12 changes: 12 additions & 0 deletions tests/lib/tokenize.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,16 @@ describe("tokenize()", () => {
espree.tokenize("foo", Object.freeze({ ecmaFeatures: Object.freeze({}) }));
});

it("should produce tokens when } is the last token", () => {
const tokens = espree.tokenize("{}");

assert.deepStrictEqual(
tester.getRaw(tokens),
[
{ type: "Punctuator", value: "{" },
{ type: "Punctuator", value: "}" }
]
);
});

});

0 comments on commit 8ba174d

Please sign in to comment.