acornjs / acorn-jsx

Alternative, faster React.js JSX parser
MIT License
648 stars 74 forks source link

Parsing error when yielding JSX without parenthesis #82

Closed kentor closed 4 years ago

kentor commented 7 years ago

Originally filed https://github.com/eslint/espree/issues/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 6 years ago

babylon fixed it here: https://github.com/babel/babel/commit/de56e12c6867e947cefc7e1b37676460b0365cb7

alexander-akait commented 4 years ago

/cc @RReverser friendly ping

RReverser commented 4 years ago

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