Saeed Heidarizarei
Saeed Heidarizarei

Reputation: 8956

There should be no space after '{' (babel/object-curly-spacing)

I'm using shift + alt + f for sorting my code in vscode but why I'm Getting This Error:?

Error:

[eslint] There should be no space after '{' (babel/object-curly-spacing)

Code:

 User.findOne({ _id: temp }, (obj) => {

After removing space before _id and after temp, I haven't any error But How Should I Fix in vscode for auto arrange?

Upvotes: 8

Views: 15060

Answers (4)

Abraham
Abraham

Reputation: 15840

To prevent vscode from addin spaces when formatting your code.

Open settings.json and add the following lines

"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,

This make the fix on both javascript and typescript formatters

Upvotes: 3

Ali Azimoshan
Ali Azimoshan

Reputation: 1361

as described in the official site eslint.org just added the blow line in .eslint.trc file

"object-curly-spacing": [2, "always"]

Upvotes: 9

Drew Cordano
Drew Cordano

Reputation: 1120

in eslint just add

rules:{
 "arraysInObjects": false,
}

or run

npm run lint -- --fix

Upvotes: 6

Barmar
Barmar

Reputation: 782785

In your VS Code settings, change javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces to false so it won't add those spaces before and after braces.

See here for more options related to formatting of Javascript code in VS.

Upvotes: 10

Related Questions