Prettier - the meaning of parantheses around assigned variables

73 Views Asked by At
  • VS Code 1.16

I format code with Prettier with formatting on save. I get weird parantheses around assigned variables;

I have these two variables

Before formatting:

   tlProjectLoader = new TimelineMax({
      paused: true
   }),

  $laoder = $(this).find('.loader');

After formatting:

  (tlProjectLoader = new TimelineMax({
    paused: true
  })),

  ($laoder = $(this).find('.loader'));

I know this is casued by Prettier, as when I turned it off and that behaviour does not occur. So, why? If I don't need it - how to turn it off?

1

There are 1 best solutions below

3
On BEST ANSWER

Seems that it happens when you declare global variables in one statement (separated by commas, instead of semicolons)

So you have two options: either use var/let/const, or separate the declarations with semicolons:

global = 123;
anotherGlobal = 345;

Tip: you can test Prettier output on the Prettier Playground