Visual Studio代码禁用对象分解的代码格式设置 我用膝关节炎和Typescript写Web应用程序。在vscode中,我遇到了不需要的代码格式设置:当我使用对象描述方法声明变量时,vscode会在多行中自动设置其格式: deleteUser: async (ctx: Context) => { const { body: { userId } } = ctx; await userService.deleteUser(userId); }

Visual Studio代码禁用对象分解的代码格式设置 我用膝关节炎和Typescript写Web应用程序。在vscode中,我遇到了不需要的代码格式设置:当我使用对象描述方法声明变量时,vscode会在多行中自动设置其格式: deleteUser: async (ctx: Context) => { const { body: { userId } } = ctx; await userService.deleteUser(userId); },typescript,visual-studio-code,formatting,tslint,object-destruction,Typescript,Visual Studio Code,Formatting,Tslint,Object Destruction,在这种情况下,我希望它保持在一行: deleteUser: async (ctx: Context) => { const { body: { userId } } = ctx; await userService.deleteUser(userId); } 我喜欢vscode处理代码格式的方式,所以我不想禁用它。但我想找到一种解决方法,在行长小于80个字符时禁用对象分解格式 我应该使用什么规则来修复此问题?我应该更改vscode规则还是tslint规则 这是我的.tslint

在这种情况下,我希望它保持在一行:

deleteUser: async (ctx: Context) => {
  const { body: { userId } } = ctx;

  await userService.deleteUser(userId);
}
我喜欢vscode处理代码格式的方式,所以我不想禁用它。但我想找到一种解决方法,在行长小于80个字符时禁用对象分解格式

我应该使用什么规则来修复此问题?我应该更改vscode规则还是tslint规则

这是我的.tslint文件:

{
  "rules": {
    "class-name": true,
    "comment-format": [true, "check-space"],
    "indent": ["tabs"],
    "one-line": [true, "check-open-brace", "check-whitespace"],
    "no-var-keyword": true,
    "quotemark": [true, "double", "avoid-escape"],
    "semicolon": [true, "always", "ignore-bound-class-methods"],
    "max-line-length": [true, 120],
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-module",
      "check-separator",
      "check-type",
      "check-preblock"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      },
      {
        "call-signature": "onespace",
        "index-signature": "onespace",
        "parameter": "onespace",
        "property-declaration": "onespace",
        "variable-declaration": "onespace"
      }
    ],
    "no-internal-module": true,
    "no-trailing-whitespace": true,
    "no-null-keyword": true,
    "prefer-const": true,
    "jsdoc-format": true
  }
}

您可以安装beautify插件并在vscode的settings.json中添加以下配置

"beautify.config": {
    "brace_style": "collapse,preserve-inline"
}

您可以安装beautify插件并在vscode的settings.json中添加以下配置

"beautify.config": {
    "brace_style": "collapse,preserve-inline"
}