Skip to content
Advertisement

How to prevent Prettier from breaking lines with comments?

For some reason Prettier breaks the line with comments moving everything after opened braсket on new line. Here is before Before auto format

And here is after After

As you can see it makes kind of random formatting: at the 1st line it moves comments to a line above, then it breaks line by brackets, then again moves comments above. I found here How to prevent Prettier from moving comments to new line it’s like impossible to prevent Prettier from moving comments to a new line, but I can’t find something about how to prevent it from breaking lines and making that bunches of cascades. Increasing Print width (line limit) does nothing, it’s 160 for me now. Any solutions?

Advertisement

Answer

Prettier is for front-end. Use Python formatter instead, for example, Black formatter.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement