Skip to content

Commit

Permalink
refactor: avoid parsing logic on locations (#13200)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Apr 25, 2021
1 parent fb908fd commit 10f4d08
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/babel-parser/src/plugins/flow/index.js
Expand Up @@ -252,16 +252,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>

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)) {
Expand Down

0 comments on commit 10f4d08

Please sign in to comment.