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

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

Closed
2 tasks done
coderaiser opened this issue Mar 4, 2023 · 7 comments · Fixed by #3676
Closed
2 tasks done

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

coderaiser opened this issue Mar 4, 2023 · 7 comments · Fixed by #3676

Comments

@coderaiser
Copy link

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

@coderaiser coderaiser added the bug label Mar 4, 2023
@ljharb
Copy link
Member

ljharb commented Mar 4, 2023

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
Copy link
Author

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

@ljharb
Copy link
Member

ljharb commented Mar 4, 2023

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

@ljharb ljharb added bug and removed enhancement labels Mar 4, 2023
@burtek
Copy link
Contributor

burtek commented Jan 9, 2024

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

@ljharb
Copy link
Member

ljharb commented Jan 10, 2024

@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
Copy link
Contributor

burtek commented Jan 10, 2024

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

@burtek
Copy link
Contributor

burtek commented Jan 10, 2024

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

ljharb pushed a commit to burtek/eslint-plugin-react that referenced this issue Jan 10, 2024
@ljharb ljharb closed this as completed in 67e669d Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants