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

📎 Implement lint/useShorthandFunctionType - typescript-eslint/prefer-function-type #48

Closed
Conaclos opened this issue Aug 23, 2023 · 8 comments · Fixed by #670
Closed
Assignees
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Comments

@Conaclos
Copy link
Member

Conaclos commented Aug 23, 2023

Description

prefer-function-type

Want to contribute? Lets you know you are interested! We will assign you to the issue to prevent several people to work on the same issue. Don't worry, we can unassign you later if you are no longer interested in the issue! Read our contributing guide and analyzer contributing guide.

@Conaclos Conaclos added the A-Linter Area: linter label Aug 23, 2023
@Conaclos Conaclos changed the title 📎 Implement lint/useShorthandFunctionType typescript-eslint/prefer-function-type 📎 Implement lint/useShorthandFunctionType - typescript-eslint/prefer-function-type Aug 23, 2023
@Conaclos Conaclos added the L-JavaScript Language: JavaScript and super languages label Aug 23, 2023
@emab
Copy link
Contributor

emab commented Oct 24, 2023

Hey @Conaclos I'd be happy to take a look at this one.

@Conaclos
Copy link
Member Author

Assigned :)

@emab
Copy link
Contributor

emab commented Oct 25, 2023

image

The eslint rule seems to show a slightly different message for the third example here... should we include this? I'm not sure if it feels a bit different from the rule we're trying to implement.

@emab
Copy link
Contributor

emab commented Oct 27, 2023

@Conaclos hope you can help me here - is there a way of converting a TsReturnTypeAnnotation into AnyTsType? I'm attempting to get the lone function definition from the interface for the fix action.

@emab
Copy link
Contributor

emab commented Oct 27, 2023

Aha, not sure what I was doing wrong but I've got it working! 😄

@emab
Copy link
Contributor

emab commented Nov 4, 2023

image The eslint rule seems to show a slightly different message for the third example here... should we include this? I'm not sure if it feels a bit different from the rule we're trying to implement.

@Conaclos what do you think about this? The returning of this doesn't seem to match the rule description as far as I can tell?

@emab
Copy link
Contributor

emab commented Nov 4, 2023

I've opened a WIP PR for this, I found it quite difficult to get to where it is now, and I feel my code is a bit messy. Would love some feedback when you have time!

@Conaclos
Copy link
Member Author

Conaclos commented Nov 4, 2023

The returning of this doesn't seem to match the rule description as far as I can tell?

I agree. I think we could just ignore a call signature that returns this or use this (or use this in the type annotation of one of its parameters).

We could add a dedicated rule for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants