Skip to content

[Bug]: Autofix do not work in react/jsx-wrap-multilines #3545

Closed
@coderaiser

Description

@coderaiser

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
    My issue appears in the command-line and not only in the text editor

Description Overview

export default () => <h1>
    <span>
        hello
    </span>
</h1>;

Error reported:
image

No fix applied

Expected Behavior

Auto fix correct code to:

export default () => (
    <h1>
        <span>
            hello
        </span>
    </h1>
);

eslint-plugin-react version

v7.32.2

eslint version

v8.35.0

node version

v18.14.2

Activity

ljharb

ljharb commented on Mar 4, 2023

@ljharb
Member

It's not a bug that a rule doesn't autofix, to be clear - not all rules autofix.

That said, it'd be great to add autofixing to this rule.

coderaiser

coderaiser commented on Mar 4, 2023

@coderaiser
Author

I see that the rule has some code that does autofix, also documentation mentioned this.

ljharb

ljharb commented on Mar 4, 2023

@ljharb
Member

ah yes, you're right, everything is passing a fixer, so there's something wrong here.

burtek

burtek commented on Jan 9, 2024

@burtek
Contributor

Tried replicating this, but it fixes that example piece of code correctly for me 🤔

ljharb

ljharb commented on Jan 10, 2024

@ljharb
Member

@burtek with what config? The test case I can get passing autofixes to:

        export default () => (<h1>
            <span>
                hello
            </span>
        </h1>);

(note the parens not being on their own lines)

burtek

burtek commented on Jan 10, 2024

@burtek
Contributor

Oh wait, missed the part where parens should be on separate lines. Will see if I can fix it quickly

burtek

burtek commented on Jan 10, 2024

@burtek
Contributor

Wait, but with what config @ljharb ? Default is parens so it works as expected. If I set arrow: 'parens-new-line' it autofixes correctly...

image

EDIT: see attached PR with tests

added a commit that references this issue on Jan 10, 2024
5a7fe04

191 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ljharb@coderaiser@burtek

      Issue actions

        [Bug]: Autofix do not work in `react/jsx-wrap-multilines` · Issue #3545 · jsx-eslint/eslint-plugin-react