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 nursery/useExplicitTypes - typescript-eslint/explicit-module-boundary-types and typescript-eslint/explicit-function-return-type #2017

Open
Conaclos opened this issue Mar 9, 2024 · 14 comments
Assignees
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Comments

@Conaclos
Copy link
Member

Conaclos commented Mar 9, 2024

Description

The rule will cover:

This rule must not conflict with noInferrableTypes.

Some context here.

@Conaclos Conaclos added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Mar 9, 2024
@Conaclos Conaclos self-assigned this Mar 9, 2024
@polar-sh polar-sh bot added the Fund label Mar 9, 2024
@Conaclos Conaclos changed the title 📎 Implement lint/useExplicitTypes - typescript-eslint/explicit-module-boundary-types and typescript-eslint/explicit-function-return-type 📎 Implement nursery/useExplicitTypes - typescript-eslint/explicit-module-boundary-types and typescript-eslint/explicit-function-return-type Mar 14, 2024
@polar-sh polar-sh bot removed the Fund label Apr 19, 2024
@barthuygen
Copy link

This is exactly the what I'm missing, is there any prospect on when this might be implemented?

@ematipico
Copy link
Member

ematipico commented Jun 5, 2024

@barthuygen

We refrain from giving dates, deadlines and such because we aren't a company and we develop things using the small resources we have.

If you're willing to see this shipped "faster" than the others, you can always help us financially: https://github.com/biomejs/biome/blob/main/GOVERNANCE.md#financial-contributions

Or willing to implement the feature yourself.

@dreamorosi
Copy link

Hi @ematipico - about the sponsorship:

  • what would be an appropriate amount of sponsorship that would secure the implementation?
  • once sponsored, what would be the estimated timeline for the feature to land in a biome version?

I can't commit to it yet, but having a discrete amount and timeline would definitely help me make a case.

@ematipico
Copy link
Member

@dreamorosi I believe we document everything inside our governance document. I suggest to reach out to us in #funding

@dreamorosi
Copy link

Hi @ematipico thanks for the reply - None of the links to Discord in the Governance document worked for me, maybe the invite link has expired. I was able to join through another link in the Contributing doc.

@RayanMoarkech
Copy link

+1 for explicit-function-return-type

@firxworx
Copy link

firxworx commented Jul 5, 2024

No kidding the explicit-function-return-type rule is the singlemost important blocker from me not ditching eslint entirely for biomejs... that plus better monorepo support but I know that's in the works. I tried biome and it is amazingly fast and nice.

Importance

TypeScript runs better and faster with explicit return types especially in large codebases, and its been known to make unexpected random performance issues disappear.

Stylistically I love it, it brings the rigour of strong-typed languages like java and makes code much easier to review and test when every function signature is a declaration of the "data in + data out" and an explicit statement of the developer's intent.

I've even watched it prevent bugs in React components during pair sessions (where this rule is sometimes accused of being annoying) e.g. if a component may conditionally return null that has to be part of the return type in addition to JSX.Element.

Suggestions

I understand the first priority is getting this rule in.

IMHO to take it to another level would be to have some more customization capabilities for it beyond what eslint provides and perhaps a "lever or knob" to control it for trivial arrow functions.

Perhaps dreaming now: a level of React awareness would be fantastic e.g. as I don't think cleanup callbacks and the like (always void) need to be declared. While I appreciate it, others would love to turn it off for React component files e.g. tsx but keep it for ts.

Perhaps to pull some of the dream requirements off as a general feature there could be a way to configure with custom patterns/regexes.

@kaykdm
Copy link
Contributor

kaykdm commented Sep 21, 2024

I have implemented the base cases of typescript-eslint/explicit-function-return-type rule. Here are the remaining TODOs, as discussed in the PR:

@nazarhussain
Copy link

I implemented allowArrowFunctions which behaves different than allowExpressions. The later restrict the rule only for expressions, but allowArrowFunctions is wider and more general for arrow functions.

Would suggest to include it as an additional feature than eslint-rule parity. #4233 What would you think?

@Conaclos
Copy link
Member Author

@nazarhussain
Could you give some examples that are not covered by allowExpressions and are covered by allowArrowFunctions? Is allowArrowFunctions compatible with TypeScript's isolated declarations?

@nazarhussain
Copy link

When an object is composed with functions, the expression definition does not apply. Check this snippet.

You will notice that allowExpressions does work when a function is passed as argument, but not when a function is used as object attributes.

@Conaclos
Copy link
Member Author

@nazarhussain Thanks for the details. I think it is worth adding these cases to the rule. However, this doesn't require an option, this should be the default behavior.

@nazarhussain
Copy link

nazarhussain commented Oct 21, 2024

@Conaclos Thanks for feedback. I will update my PR accordingly and extend the rule without adding a new option.

@nazarhussain
Copy link

@Conaclos I updated the PR, please review when available #4233

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

No branches or pull requests

8 participants