vscode/Prettier/Eslint在可选链接操作员中添加空间
不确定发生了什么,但是在vscode w/ eslint和Prettier打开中,它会继续转换这样的行var?.foo?.bar?.bar to
var? .foo? .bar
然后引发语法错误...我有以下内容:
{
"trailingComma": "all",
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true
}
{
"extends": ["airbnb", "airbnb-typescript"],
"parserOptions": {
"project": "./tsconfig.json"
},
"parser": "@babel/eslint-parser",
"rules": {
"@typescript-eslint/semi": "off",
"semi": "off",
"import/prefer-default-export": "off",
"no-unused-vars": ["error", { "argsIgnorePattern": "next" }],
"react/react-in-jsx-scope": "off",
"react/jsx-one-expression-per-line": "off",
"react/jsx-props-no-spreading": "off",
"jsx-a11y/label-has-associated-control": "off",
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
"react/function-component-definition": "off",
"react/require-default-props": "off",
"no-param-reassign": "off"
}
}
如何停止vscode添加这些空间?
Not sure what's going on, but in VSCode w/ ESLint and Prettier turned on, it keeps converting lines like this var?.foo?.bar
into var ? .foo ? .bar
which then throws syntax errors... I have the following:
{
"trailingComma": "all",
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true
}
{
"extends": ["airbnb", "airbnb-typescript"],
"parserOptions": {
"project": "./tsconfig.json"
},
"parser": "@babel/eslint-parser",
"rules": {
"@typescript-eslint/semi": "off",
"semi": "off",
"import/prefer-default-export": "off",
"no-unused-vars": ["error", { "argsIgnorePattern": "next" }],
"react/react-in-jsx-scope": "off",
"react/jsx-one-expression-per-line": "off",
"react/jsx-props-no-spreading": "off",
"jsx-a11y/label-has-associated-control": "off",
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
"react/function-component-definition": "off",
"react/require-default-props": "off",
"no-param-reassign": "off"
}
}
How do I stop VSCode from adding those spaces?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能在这里有点晚,但是至少对我来说,这个问题是由使用另一个扩展名而不是Eslint的“美化”格式的VSCODE引起的。我必须打开命令调色板(
ctrl + shift + p
),然后选择>格式文档,然后使用...
,然后在底部选择配置
配置默认值格式化
,然后选择ESLINT作为默认值。I may be a bit late here, but at least for me, this issue was caused by VSCode using a 'Beautify' formatter from another extension, rather than ESlint. I had to open the command palette (
Ctrl + Shift + P
), then select>Format document with...
, then at the bottom selectConfigure default formatter
, and select ESlint as the default.我安装了Eslint扩展名,并选择它作为格式化.js文件的默认值
,并且可以正常工作
I Installed Eslint extension and choose it as the default value for formatting .js files
and it works fine