File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,9 @@ module.exports = () => Parser => class Espree extends Parser {
175
175
this . next ( ) ;
176
176
} while ( this . type !== tokTypes . eof ) ;
177
177
178
+ // Consume the final eof token
179
+ this . next ( ) ;
180
+
178
181
const extra = this [ STATE ] ;
179
182
const tokens = extra . tokens ;
180
183
Original file line number Diff line number Diff line change @@ -199,4 +199,20 @@ describe("tokenize()", () => {
199
199
espree . tokenize ( "foo" , Object . freeze ( { ecmaFeatures : Object . freeze ( { } ) } ) ) ;
200
200
} ) ;
201
201
202
+ /**
203
+ * Make sure we tokenize closing curly brace in a block statement at end of file
204
+ * @see https://github.com/eslint/espree/issues/403 for more information
205
+ */
206
+ it ( "should produce tokens when } is the last token" , ( ) => {
207
+ const tokens = espree . tokenize ( "{}" ) ;
208
+
209
+ assert . deepStrictEqual (
210
+ tester . getRaw ( tokens ) ,
211
+ [
212
+ { type : "Punctuator" , value : "{" } ,
213
+ { type : "Punctuator" , value : "}" }
214
+ ]
215
+ ) ;
216
+ } ) ;
217
+
202
218
} ) ;
You can’t perform that action at this time.
0 commit comments