Report a SyntaxError for } and > in JSX text (#12451)

cherry-pick  #11046

Co-Authored-By: Kai Cataldo <kai@kaicataldo.com>
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
Co-authored-by: Kai Cataldo <kai@kaicataldo.com>
This commit is contained in:
Nicolò Ribaudo
2020-12-28 19:04:54 +01:00
committed by GitHub
parent 0dbc3dd4a0
commit fbef603c43
19 changed files with 357 additions and 106 deletions

View File

@@ -125,6 +125,19 @@ export default (superClass: Class<Parser>): Class<Parser> =>
chunkStart = this.state.pos;
break;
case charCodes.greaterThan:
case charCodes.rightCurlyBrace:
if (process.env.BABEL_8_BREAKING) {
const htmlEntity =
ch === charCodes.rightCurlyBrace ? "&rbrace;" : "&gt;";
const char = this.input[this.state.pos];
this.raise(
this.state.pos,
`Unexpected token \`${char}\`. Did you mean \`${htmlEntity}\` or \`{'${char}'}\`?`,
);
}
/* falls through */
default:
if (isNewLine(ch)) {
out += this.input.slice(chunkStart, this.state.pos);