From 10f4d08efbba49b4085f0756b59c835f97783fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Sun, 25 Apr 2021 09:15:48 -0400 Subject: [PATCH] refactor: avoid parsing logic on locations (#13200) --- packages/babel-parser/src/plugins/flow/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/babel-parser/src/plugins/flow/index.js b/packages/babel-parser/src/plugins/flow/index.js index 01bf25e2f351..8dba2a977a6e 100644 --- a/packages/babel-parser/src/plugins/flow/index.js +++ b/packages/babel-parser/src/plugins/flow/index.js @@ -252,16 +252,11 @@ export default (superClass: Class): Class => flowParsePredicate(): N.FlowType { const node = this.startNode(); - const moduloLoc = this.state.startLoc; const moduloPos = this.state.start; - this.expect(tt.modulo); - const checksLoc = this.state.startLoc; + this.next(); // eat `%` this.expectContextual("checks"); // Force '%' and 'checks' to be adjacent - if ( - moduloLoc.line !== checksLoc.line || - moduloLoc.column !== checksLoc.column - 1 - ) { + if (this.state.lastTokStart > moduloPos + 1) { this.raise(moduloPos, FlowErrors.UnexpectedSpaceBetweenModuloChecks); } if (this.eat(tt.parenL)) {