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

fix: ensure rule fixes produce valid code when function params and args have trailing commas #1282

Merged
merged 1 commit into from
Nov 24, 2022

Conversation

G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Nov 10, 2022

The fix that no one asked for 😄 props to @berkinanik for bring this to my attention over in eslint-plugin-jest-dom.

Weirdly ESLint doesn't seem to think some of the result syntax before this is invalid (namely in no-done-callback which'd give ((), ) => {}), but didn't feel like digging into that further right now.

@@ -89,7 +107,7 @@ ruleTester.run('no-done-callback', rule, {
messageId: 'suggestWrappingInPromise',
data: { callback: 'done' },
output:
'test("something", () => {return new Promise((done) => {done();})})',
'test("something", () => {return new Promise(done => {done();})})',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should probably preserve the parens if they were there originally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice for fixers are to avoid doing stylistic fixes since that should be enforced by another rule (which will be automatically fixed if possible), to help keep fixes as small as possible.

@G-Rath G-Rath merged commit 8eca0b7 into main Nov 24, 2022
@G-Rath G-Rath deleted the fix-trailing-comma-handling branch November 24, 2022 19:50
github-actions bot pushed a commit that referenced this pull request Nov 24, 2022
## [27.1.6](v27.1.5...v27.1.6) (2022-11-24)

### Bug Fixes

* ensure rule fixes produce valid code when function params and args have trailing commas ([#1282](#1282)) ([8eca0b7](8eca0b7))
@github-actions
Copy link

🎉 This PR is included in version 27.1.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants