refactor: avoid parsing logic on locations (#13200)

This commit is contained in:
Huáng Jùnliàng 2021-04-25 09:15:48 -04:00 committed by GitHub
parent fb908fd87e
commit 10f4d08efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)) {