[babel 8] Disallow sequence expressions in JSX expression containers#12447
Conversation
* jsx: fix sequence expression at JSXAttributeValue * Change logic for detecting unparenthesized expressions * use parseMaybeAssign instead of custom error handling Co-authored-by: Daniel Tschinder <[email protected]> Co-authored-by: Nicolò Ribaudo <[email protected]>
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a052169:
|
| // env vars from the cli are always strings, so !!ENV_VAR returns true for "false" | ||
| function bool(value) { | ||
| return value && value === "false" && value === "0"; | ||
| return value && value !== "false" && value !== "0"; |
There was a problem hiding this comment.
This was a stupid error 😁
"true" -> true
"false" -> false
"0" -> false
"1" -> true
undefined -> undefined|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/34069/ |
| node.expression = this.parseExpression(); | ||
| node.expression = process.env.BABEL_8_BREAKING | ||
| ? this.parseMaybeAssign() | ||
| : this.parseExpression(); |
There was a problem hiding this comment.
Consider throw recoverable error if node.expression is an unparenthesized SequenceExpression.
There was a problem hiding this comment.
Could we do that as a follow up? 🙏
I'd like to keep the PR as similar as possible to the one I'm backporting from next-8-dev
There was a problem hiding this comment.
Nah, I can do it here
JLHwung
left a comment
There was a problem hiding this comment.
Did you mean JSXChildren? JSXAttributes exist in open/close JSX element only.
This is a "backport" of #8787 from
next-8-devtomain. It's disabled by default, unless you run (if working in the monorepo) or build (if publishing) babel withBABEL_8_BREAKING=true.This cannot be enabled by Babel consumers.
Original PR: #8787 (already reviewed)
Original PR description:
Throw a recoverable error) was not in the original PR.