Skip to content

jsx-curly-spacing autofix deletes comments #648

Closed
@lencioni

Description

@lencioni
Collaborator

If I have some JSX like:

<div>
  { /* comment */ }
</div>

the autofixer will change it to:

<div>
  {}
</div>

but it should change it to:

<div>
  {/* comment */}
</div>

Activity

ahstro

ahstro commented on Nov 30, 2016

@ahstro

Title should probably be changed to "jsx-curly-spacing doesn't account for comments" since things like {something /* comment */} triggers an error.

s-h-a-d-o-w

s-h-a-d-o-w commented on Sep 6, 2017

@s-h-a-d-o-w
Contributor

@yannickcr Your commit unfortunately doesn't seem to fix this issue. The example provided by @lencioni still produces the buggy result of removing the comment (tested using 7.3.0).

So I would argue that this issue should be re-opened.

ljharb

ljharb commented on Sep 6, 2017

@ljharb
Member

The commit includes automated tests that should verify it's working.

Can you open a PR that includes a failing test case?

s-h-a-d-o-w

s-h-a-d-o-w commented on Sep 12, 2017

@s-h-a-d-o-w
Contributor

Was that what you had in mind?

ljharb

ljharb commented on Sep 12, 2017

@ljharb
Member

Thanks, that's appreciated! I'll take a look soon.

s-h-a-d-o-w

s-h-a-d-o-w commented on Sep 12, 2017

@s-h-a-d-o-w
Contributor

Cool, thanks for the update!
(Essentially my first PR on a major project, so I just wanted to make sure I did it properly and understood you correctly :) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@lencioni@ahstro@s-h-a-d-o-w

        Issue actions

          jsx-curly-spacing autofix deletes comments · Issue #648 · jsx-eslint/eslint-plugin-react