-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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: object-shorthand providing invalid fixes for typescript #12260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raising one question.
I'm personally in favor of adding a test that simulates the Typescript case, but I'll defer to team consensus on that one.
I've refactored the code so it doesn't rely on a check for I've also added a test with typescript code to help prevent a regression. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
What is the purpose of this pull request? (put an "X" next to item)
[x] Bug fix
Related: typescript-eslint/typescript-eslint#124
The bug is that currently the fixer adds extra parentheses when fixing a TS arrow function with a return type:
This happens because the rule currently searches backwards from the
=>
to find a)
, to determine if it should wrap the arguments in parentheses. It obviously instead finds a return type annotation, hence the breakage.What changes did you make? (Give an overview)
Adjusted the fix algorithm for arrow functions so that it searches from the start of the arrow function expression instead.
I added a TS-specific test for this - happy to remove it if you don't want the burden.