Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jsx parser missing plugins errors #11499 #11629

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/babel-parser/src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,12 @@ export default class ExpressionParser extends LValParser {
}
}
// fall through
case tt.relational: {
if (this.state.value === "<") {
this.expectPlugin("jsx");
}
}
// fall through
default:
throw this.unexpected();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>() => {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"throws": "This experimental syntax requires enabling the parser plugin: 'jsx' (1:0)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could throw this.expectOnePlugin(["jsx", "flow", "typescript"]) to give an error that is also correct in this case?

"plugins": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"throws": "This experimental syntax requires enabling the parser plugin: 'jsx' (1:0)",
"plugins": []
}