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: syntax error in prefer-arrow-callback autofix #16718

Closed
1 task done
fasttime opened this issue Dec 28, 2022 · 2 comments · Fixed by #16722
Closed
1 task done

Bug: syntax error in prefer-arrow-callback autofix #16718

fasttime opened this issue Dec 28, 2022 · 2 comments · Fixed by #16722
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion autofix This change is related to ESLint's autofixing capabilities bug ESLint is working incorrectly repro:yes rule Relates to ESLint's core rules
Projects

Comments

@fasttime
Copy link
Member

fasttime commented Dec 28, 2022

Environment

Node version: v19.3.0
npm version: v9.2.0
Local ESLint version: v8.30.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 22.1.0

What parser are you using?

Default (Espree)

What did you do?

Configuration
{
    "parserOptions": {
        "ecmaVersion": "latest"
    },
    "rules": {
        "prefer-arrow-callback": [
            "error"
        ]
    }
}
test(
  function ()
  { }
);

What did you expect to happen?

Autofix should fix the code like this:

test(
  () =>
  { }
);

What actually happened?

Autofix produces unparseable code:

test(
  ()
  => { }
);

DEMO LINK

The problem occurs when the function body starts on a new line, like in the Allman style.

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@fasttime fasttime added bug ESLint is working incorrectly repro:needed labels Dec 28, 2022
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Dec 28, 2022
@fasttime fasttime changed the title Bug: (fill in) syntax error in prefer-arrow-callback autofix Bug: syntax error in prefer-arrow-callback autofix Dec 28, 2022
@mdjermanovic mdjermanovic moved this from Needs Triage to Triaging in Triage Dec 28, 2022
@mdjermanovic mdjermanovic added repro:yes rule Relates to ESLint's core rules autofix This change is related to ESLint's autofixing capabilities accepted There is consensus among the team that this change meets the criteria for inclusion and removed repro:needed labels Dec 28, 2022
@mdjermanovic mdjermanovic moved this from Triaging to Ready to Implement in Triage Dec 28, 2022
@mdjermanovic
Copy link
Member

Accepted, PR is welcome!

@fasttime
Copy link
Member Author

Thanks for accepting this, @mdjermanovic. I'll work on a fix.

Triage automation moved this from Ready to Implement to Complete Dec 31, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jun 30, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion autofix This change is related to ESLint's autofixing capabilities bug ESLint is working incorrectly repro:yes rule Relates to ESLint's core rules
Projects
Archived in project
Triage
Complete
Development

Successfully merging a pull request may close this issue.

2 participants