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

Comments in JSX/TSX #11647

Open
cotneit opened this issue Sep 6, 2024 · 4 comments
Open

Comments in JSX/TSX #11647

cotneit opened this issue Sep 6, 2024 · 4 comments
Labels
C-enhancement Category: Improvements

Comments

@cotneit
Copy link
Contributor

cotneit commented Sep 6, 2024

Comments in JSX are a bit special, and it would be nice if Helix could handle them a bit better than it does now when it comes to commenting and uncommenting.

JS comments (// and /* */) are not valid where a JSXChild is expected, but they become valid when wrapped in curly braces {} since then they are treated as JSXChildExpression, and it being optional the entire thing can be a comment, resulting in {/* */} essentially being a block comment token pair for this particular case.

In every other case inside a JSX file regular JS comments are valid and should be preferred over {/* */}.

For example, every comment here is valid:

const Thingy = <>
    {/* <div></div> */}

    <div
        // id="main" style="color: blue"
        /* id="main" style="color: red" */

        thingy={
            // <div></div>
            <div>
                {/* <div>Lorem</div> */}
            </div>
        }
    >
        {/* <div>Lorem</div> */}
    </div>
</>

Looks like VS Code implements this by injecting a special language:

I imagine this could be replicated in Helix, but currently injection comment tokens are ignored, so I would consider this to be blocked:

That said, I don't think these issues being resolved will result in JSX/TSX comments working properly without additional efforts, hence this issue. I could be wrong.


Prior issues on this topic:

@cotneit cotneit added the C-enhancement Category: Improvements label Sep 6, 2024
@Nikita0x
Copy link
Contributor

I don't want to create a new issue, just gonna leave it here maybe?

Comments are incorrectly inferred in Vue.js (.vue) files as well
incorrect comment

@DoctorRyner
Copy link

It's really annoying that I can't properly comment big chunks of html in jsx files

@Nikita0x
Copy link
Contributor

It's really annoying that I can't properly comment big chunks of html in jsx files

They're working on it, here:

@DoctorRyner
Copy link

DoctorRyner commented Sep 20, 2024

@Nikita0x oh, I hope so. Because there are less and less commits with any changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants