acornjs/acorn-jsx

Parsing error when yielding JSX without parenthesis

Closed this issue · 3 comments

Originally filed eslint/espree#355 but was told to file it here:

Currently we get a parsing error Unexpected token < with this:

function* test() {
  yield <Hey />;
}

https://astexplorer.net/#/gist/a96aa934d341355b14576ef0e006b02a/97e8c8019fd5610b88d9403b61406707188d8d1c

However, if you use the babylon7 parser it works.

I used to just add parens around the JSX for this to work:

function* test() {
  yield (<Hey />);
}

But it is now an issue when using eslint + eslint-plugin-prettier because prettier removes the parens and then eslint (using espree) gets a parsing error after that.

danez commented

babylon fixed it here:
babel/babel@de56e12

/cc @RReverser friendly ping

Looks like the port from Babylon should be easy, I'm happy to accept a PR.