Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Setting to push JavaScript objects inside arrays to new line

Is there a VS Code extension setting that, when using formatOnSave, will force object-literal curly-brackets for the first object in an array to start on the next line?

Trying to achieve this:

const arrOfObjs = [
  {
    name: 'Obj1'
  },
  {
    name: 'Obj2'
  }
];

But instead, the formatter brings the first obj curly up on the same line as the array bracket:

const arrOfObjs = [{
    name: 'Obj1'
  },
  {
    name: 'Obj2'
  }
];

That makes ESLint yell about indents (expecting 2 but found 4). Right now I am ignoring the error for the one time in my code this happens, but I'll continue to feel dirty until I can get these two things to work together. :)

like image 846
Jim Avatar asked Jul 27 '26 09:07

Jim


1 Answers

Probably is a conflict between VSCode and ESLin, both are formatting at the same time, let ESLint manage the formatting put: "editor.formatOnSave": false and "eslint.autoFixOnSave": true

like image 66
ramirozap Avatar answered Jul 29 '26 21:07

ramirozap



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!