Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@alexbrooklyn This is a minimal example, in the real situation the callback is ~10 lines long and not just a single function call.
-
@alexbrooklyn And processResult may not call its argument or may do some postprocessing on the return value as well
-
10Dev28544yI've always found it funny how tools/frameworks use both 'opinionated' and 'unopinionated' as positive adjectives
-
Idk what you expected, but this looks pretty consistent and good practice.
Try setting the column width to something like 120/180 and it’s probably gonna keep it in one line.
Also, prettier prefers to keep the contents of new contexts in new lines. This is also probably the reason it breaks like this. Remove the brackets may help, if the function body isn’t much. -
@petergriffin The function body is really long and I don't want wide lines. Also, imagine a lot of these one after another, like an express or fastify routing config, some of them with and some without a mixin.
-
@iiii The problem isn't with the second one. The problem is that these two are very similar things made to look very different by Prettier. Even the indentation levels are different. They look absolutely disgusting intermixed in a file that contains 6 different endpoints.
-
iiii90854y@homo-lorens they are not "very similar". You have double nested stuff in the second one. And the line leading to the lambda is too long to place the contents just one indentation deep, because the context is lost somewhere at the end of the long ass previous line.
Prettier did its job: make shit reasonably readable. -
@iiii Well yeah, if you just apply the rules like any well programmed tool then this is very complex and very different. If you try to understand it then it's just a mixin and should look roughly the same as a mixin-free callback to avoid needless noise.
-
@iiii I could settle for the second method being applied in both cases. My main problem is that Prettier doesn't allow me to configure this either in order to "prevent debates about coding style" as if it's a bad thing to decide on something the majority likes and lends itself to the individual techniques - callbacks and mixins in this case.
-
@Berkmann18 @hack This is a minimál example, the actual code is much more complex and doesn't fit on one line.
Related Rants
Prettier breaks mixin formatting and there's absolutely no way to configure it.
Disgusting, right?
And this is why "opinionated" is a negative adjective and its positive counterpart is "adaptable".
rant
adaptable
opinionated
prettier
js
mixins