简体   繁体   中英

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?

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.

如官方网站eslint.org 中所述,刚刚在.eslint.trc文件中添加了吹线

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

in eslint just add

rules:{
 "arraysInObjects": false,
}

or run

npm run lint -- --fix

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM