Open Conaclos opened 8 months ago
This is exactly the what I'm missing, is there any prospect on when this might be implemented?
@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.
Hi @ematipico - about the sponsorship:
I can't commit to it yet, but having a discrete amount and timeline would definitely help me make a case.
@dreamorosi I believe we document everything inside our governance document. I suggest to reach out to us in #funding
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.
+1 for explicit-function-return-type
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.
I have implemented the base cases of typescript-eslint/explicit-function-return-type
rule. Here are the remaining TODOs, as discussed in the PR:
allowHigherOrderFunctions
in typescript-eslint) - https://github.com/biomejs/biome/pull/4117allowTypedFunctionExpressions
in typescript-eslint) - https://github.com/biomejs/biome/pull/4174const
assertions in arrow functions (allowDirectConstAssertionInArrowFunctions
in typescript-eslint) - https://github.com/biomejs/biome/pull/4027allowExpressions
in typescript-eslint) - https://github.com/biomejs/biome/pull/4036I 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. https://github.com/biomejs/biome/pull/4233 What would you think?
@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?
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.
@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.
@Conaclos Thanks for feedback. I will update my PR accordingly and extend the rule without adding a new option.
@Conaclos I updated the PR, please review when available https://github.com/biomejs/biome/pull/4233
Description
The rule will cover:
This rule must not conflict with noInferrableTypes.
Some context here.