8
lorentz
3y

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".

Comments
  • 0
    Can't you directly supply 'handle' in the processResult?
  • 0
    @alexbrooklyn This is a minimal example, in the real situation the callback is ~10 lines long and not just a single function call.
  • 0
    @alexbrooklyn And processResult may not call its argument or may do some postprocessing on the return value as well
  • 1
    I've always found it funny how tools/frameworks use both 'opinionated' and 'unopinionated' as positive adjectives
  • 1
    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.
  • 0
    @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.
  • 1
    What is even wrong with the second one?
  • 0
    @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.
  • 2
    @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.
  • 0
    @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.
  • 1
    @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.
  • 1
    Wondering what happens when you remove curly braces
  • 0
    @homo-lorens use something else other than prettier?
  • 0
    That issue would have been solved if you set the printWidth to a higher value.
  • 0
    @Berkmann18 @hack This is a minimál example, the actual code is much more complex and doesn't fit on one line.
  • 0
    @iiii And that's exactly what i did after i realised this.
  • 0
    Until async await save the day
  • 0
    @jak645 Actually this is a route handler. Would be nice though.
Add Comment