Nicolò Ribaudo b422c7f0ef
[babel 8] Disallow sequence expressions in JSX expression containers (#12447)
* jsx: fix sequence expression at JSXAttributeValue (#8787)

* jsx: fix sequence expression at JSXAttributeValue

* Change logic for detecting unparenthesized expressions

* use parseMaybeAssign instead of custom error handling

Co-authored-by: Daniel Tschinder <daniel@tschinder.de>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* I'm not good at booleans

* Format

* Throw a recoverable error

Co-authored-by: Bruno Macabeus <macabeus@users.noreply.github.com>
Co-authored-by: Daniel Tschinder <daniel@tschinder.de>
2020-12-08 10:15:03 +01:00

112 lines
4.8 KiB
JSON

{
"type": "File",
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":54}},
"errors": [
"SyntaxError: Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)? (1:26)"
],
"program": {
"type": "Program",
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":54}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":54}},
"expression": {
"type": "JSXElement",
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":54}},
"openingElement": {
"type": "JSXOpeningElement",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}},
"name": {
"type": "JSXIdentifier",
"start":1,"end":4,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":4}},
"name": "div"
},
"attributes": [],
"selfClosing": false
},
"closingElement": {
"type": "JSXClosingElement",
"start":48,"end":54,"loc":{"start":{"line":1,"column":48},"end":{"line":1,"column":54}},
"name": {
"type": "JSXIdentifier",
"start":50,"end":53,"loc":{"start":{"line":1,"column":50},"end":{"line":1,"column":53}},
"name": "div"
}
},
"children": [
{
"type": "JSXExpressionContainer",
"start":5,"end":48,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":48}},
"expression": {
"type": "SequenceExpression",
"start":6,"end":47,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":47}},
"expressions": [
{
"type": "CallExpression",
"start":6,"end":24,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":24}},
"callee": {
"type": "MemberExpression",
"start":6,"end":17,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":17}},
"object": {
"type": "Identifier",
"start":6,"end":13,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":13},"identifierName":"console"},
"name": "console"
},
"computed": false,
"property": {
"type": "Identifier",
"start":14,"end":17,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":17},"identifierName":"log"},
"name": "log"
}
},
"arguments": [
{
"type": "StringLiteral",
"start":18,"end":23,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":23}},
"extra": {
"rawValue": "foo",
"raw": "'foo'"
},
"value": "foo"
}
]
},
{
"type": "CallExpression",
"start":26,"end":47,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":47}},
"callee": {
"type": "MemberExpression",
"start":26,"end":40,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":40}},
"object": {
"type": "Identifier",
"start":26,"end":30,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":30},"identifierName":"JSON"},
"name": "JSON"
},
"computed": false,
"property": {
"type": "Identifier",
"start":31,"end":40,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":40},"identifierName":"stringify"},
"name": "stringify"
}
},
"arguments": [
{
"type": "Identifier",
"start":41,"end":46,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":46},"identifierName":"props"},
"name": "props"
}
]
}
]
}
}
]
}
}
],
"directives": []
}
}