Alex Florin
Alex Florin

Reputation: 431

Visual Code/WebStorm behave differently when indenting multiline assignment operator

I have the following lines of code:

const [
    a,
    b,
    c,
    d,
] = [
    ...someArray,
    ...someOtherArray,
];

WebStorm formats these lines as shown above, but Visual Studio Code formats them as follows:

const [
    a,
    b,
    c,
    d,
] = [
        ...someArray,
        ...someOtherArray,
    ];

None of them have code formatting plugins - just the default packages that they come with. I don't really have a preference towards any of the 2 ways, but I want a consistent behavior between the two editors and I can't find the setting which influences the indent decision in this case. I've spent hours scrolling through every possible code formatting option in both editors, but the indent decision seems to come out of thin air. Does anyone know where or how can I modify it?

It's worth mentioning that if the code looks like this:

const [a, b, c, d] = [
    ...someArray,
    ...someOtherArray,
];

then both editors format it as above. The issue seems to be when the = operator is on a new line.

Upvotes: 0

Views: 414

Answers (1)

Spark
Spark

Reputation: 86

It looks like you just need to change the indentation in vscode and webstorm settings to the same value. To use spaces or tab and 2 or 4 indentation size.

Upvotes: 0

Related Questions