- 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?
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:Tip: you can test Prettier output on the Prettier Playground