![](/img/trans.png)
[英]There should be no space after '{' (babel/object-curly-spacing)
[英]How do I disable There should be no space after '{'.eslintobject-curly-spacing in .eslintrc.js
我正在使用 prettier,並使用帶有 eslint 選項的 firebase init 初始化了我的項目。 但是當我保存文件時,更漂亮的擴展在 object 花括號中添加間距,如下所示:
export { basicHTTP } from './http';
這是 firebase init 附帶的 my.eslintrc.js 文件:
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'google',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.dev.json'],
tsconfigRootDir: __dirname,
sourceType: 'module',
},
ignorePatterns: [
'/lib/**/*', // Ignore built files.
],
plugins: ['@typescript-eslint', 'import'],
rules: {
quotes: ['error'],
},
};
將您的rules
修改為如下所示:
rules: {
'object-curly-spacing': ['error', 'always'],
'quotes': ['error'],
},
在此更改之后,您可能必須修復所有 js 文件以使用相同的語法,但這只是一個好習慣。
您可以在格式化代碼時禁用在vscode
中添加空格。
打開settings.json
並添加以下行
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
這將在 javascript 和 typescript 上修復它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.