-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Ignores comment after generic JsxOpeningElement #583
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
Comments
Feel free to submit a PR if you would like. |
Is this actually valid JSX? I thought JS comments had to be inside curly braces in JSX. |
Having a look at the react docs, they don't say anything specifically about comments within a JSX tag.
Looking in astexplorer, all of the babel parsers seem to handle it. We should probably look for parity with babel in this regard, if only because I assume the react team contributes to that portion of the parser and so is a defacto standard. |
In the examples given here, it does look like comments can exist within a tag. The curly braces are only needed to ensure it doesn’t get rendered as a text node. TIL! |
Uh oh!
There was an error while loading. Please reload this page.
What code were you trying to parse?
What did you expect to happen?
A comment node "Foo" should be included somewhere
What actually happened?
Comment "Foo" is ignored and this affects Prettier making we drop comments (see: prettier/prettier#6012).
I'm not familiar with TypeScript parser API, but I tested a few things and if I comment the following
case
condition, it works:typescript-eslint/packages/typescript-estree/src/convert-comments.ts
Lines 118 to 130 in 50a493e
Maybe that helps to identify the problem.
I'm willing to contribute with a fix if you have your hands full, but I need to learn what that code does. Let me know if you need help.
Versions
Tested in master.
Pinging @JamesHenry
The text was updated successfully, but these errors were encountered: