Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prettier in VS Code formatting (new lines before arguments)

I'm using Angular Essentials by John Papa - in particular, Tslint and Prettier. For some reason, it transforms this code

this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size;
this.rM.vA = Math.max(Math.min(this.rM.startVA + 2 * diffY * 180 / size, 90), -90);

into this

this.rM.hA =
  this.rM.startHA + 2 * diffX * 360 / size;
this.rM.vA = Math.max(
  Math.min(
    this.rM.startVA + 2 * diffY * 180 / size,
    90
  ),
  -90
);

How can i avoid it? I've tried to play with tslint.json settings:

"max-line-length": [true, 165]

But that one does not affect in my case.

EDIT: as following the similar issue I've tried to set both "prettier.printWidth" and "editor.wordWrap", but none of them helped. I've removed max-line-length, as suggested by @ConnorsFan, and my current Workspace Settings (which should override Users Settings, right?) is

{
"prettier.printWidth": 180,
"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 180 }

EDIT2: it appears, problem is caused by Prettier extension (comes as dependency for Angular Essentials). Now the problem is narrowed to realize, why "prettier.printWidth": 180 is not working. I've opened an issue https://github.com/prettier/prettier/issues/3228

PS: The names have been changed to protect the innocent. (c)

like image 761
Vitalii Vasylenko Avatar asked Nov 09 '17 19:11

Vitalii Vasylenko


People also ask

How do you stop Prettier in VS Code splitting attributes onto multiple lines?

A quick fix is to go to Prettier Extension Settings (ctrl + shift + X) and in Prettier Extension Settings search for "Print Width" set it to 250 or anything that works for you.


1 Answers

"prettier.printWidth": 120 worked for me with only having two javascript format extensions 'Prettier' & 'ESlint' in my vscode.

like image 152
sknight Avatar answered Oct 23 '22 06:10

sknight