Report functions in let expressions that do not depend on local values #93
jfmengels
started this conversation in
Rule ideas
Replies: 1 comment
-
Could what? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What the rule should do:
Report functions in let expressions that do not depend on local values
Prior work:
elm-analyse
has a rule to forbid functions in let expressions, regardless of how they are used. https://stil4m.github.io/elm-analyse/#/messages/FunctionInLetI don't like this rule and disabled it when I was using
elm-analyse
because functions could be using closures in an aim to make the code using it simpler.What problems does it solve:
Making functions much smaller in a way that makes them much more readable IMO.
I don't know if defining functions inside let expressions adds a performance cost because the functions would be redefined at every call.
Example of things the rule would report:
Example of things the rule would not report:
When (not) to enable this rule:
Only enable if if you care about this kind of cleanup? 🤷♂️
Questions I have
If so, in the following example
secondsInMinute
should be moved to the top-level.I'd say why not, but it might be too much? Note that point-free functions look like constants, especially without type annotations
Beta Was this translation helpful? Give feedback.
All reactions