简体   繁体   English

'{' 后不应有空格(babel/object-curly-spacing)

[英]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:?我正在使用shift + alt + fvscode对我的代码进行排序,但为什么会出现此错误:?

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?在 _id 之前和 temp 之后删除空间后,我没有任何错误但是我应该如何在 vscode 中修复以进行自动排列?

In your VS Code settings, change javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces to false so it won't add those spaces before and after braces . 在您的VS Code设置中,将javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces更改为false这样就不会在花braces之前和之后添加这些空格。

See here for more options related to formatting of Javascript code in VS. 有关与VS中Javascript代码格式相关的更多选项,请参见此处

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

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

in eslint just add在 eslint 中添加

rules:{
 "arraysInObjects": false,
}

or run或运行

npm run lint -- --fix

To prevent vscode from addin spaces when formatting your code.防止vscode在格式化代码时添加空格。

Open settings.json and add the following lines打开settings.json并添加以下几行

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

This make the fix on both javascript and typescript formatters这对 javascript 和 typescript 格式化程序进行了修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 什么时候应该在花括号后使用分号? - When should I use a semicolon after curly braces? VS Code 在符号后添加空格 = + 如何去掉空格 - VS Code add spacing after signs = + how to remove the space JSX react/jsx-curly-spacing IntelliJ - JSX react/jsx-curly-spacing IntelliJ Babel 期望“,”应该有一个“.”? - Babel expects “,” where there should be a “.”? 对象在 babel 变换后不支持这个动作 new x() - object doesn't support this action new x() after babel transform 使用 flex-wrap 包裹物品后,移除右侧的多余空间,同时保持物品之间的间距相等 - remove extra space on the right after the wrapping of items with flex-wrap, while maintaining equal spacing between items 按空格分割,保留大括号但包含空格 - Split by space, preserve curly brackets but include spaces 应该在哪里使用哪个支架? object 解构时方括号或花括号? 我很想使用上下文但有点困惑 - Which brackest should be used where ? square brackets or curly braces while object destructuring ? I'm tyring to use context but bit confused 在 ReactJS 中的数组 object 之后添加空格 - Add space after array object in ReactJS ESLint - 对象卷曲换行符 - ESLint - object-curly-newline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM