我不希望 WebStorm 删除 "import { Injectable } ..." 之间的空格

I don't want WebStorm to remove the spaces between "import { Injectable } ..."

当我按 Ctrl + Alt + L 重新格式化代码时,它将 import { Injectable } 转换为 import {Injectable}。我不喜欢那样。我该如何解决?

import { Injectable } from '@angular/core';
import { TranslateService, LangChangeEvent } from '@ngx-translate/core';
import { Subscription } from 'rxjs';

import { Logger } from '../core';
import enUS from '../../translations/en-US.json';
import bgBG from '../../translations/bg-BG.json';

const log = new Logger('I18nService');
const languageKey = 'language';

@Injectable({
  providedIn: 'root'
})
export class I18nService {

tslint.json

不确定是否必须通过 WebStorm 或 tslint 配置进行,所以我将 tslint 配置粘贴在这里,以防万一。

{
  "extends": "tslint:recommended",
  "rules": {
    "align": {
      "options": [
        "parameters",
        "statements"
      ]
    },
    "array-type": false,
    "arrow-parens": false,
    "arrow-return-shorthand": true,
    "curly": true,
    "deprecation": {
      "severity": "warning"
    },
    "component-class-suffix": true,
    "contextual-lifecycle": true,
    "directive-class-suffix": true,
    "directive-selector": [
      true,
      "attribute",
      "vex",
      "camelCase"
    ],
    "component-selector": [
      true,
      "element",
      "vex",
      "kebab-case"
    ],
    "eofline": true,
    "import-blacklist": [
      true,
      "rxjs/Rx"
    ],
    "import-spacing": true,
    "indent": {
      "options": [
        "spaces"
      ]
    },
    "interface-name": false,
    "max-classes-per-file": false,
    "max-line-length": [
      true,
      140
    ],
    "member-access": false,
    "member-ordering": [
      true,
      {
        "order": [
          "static-field",
          "instance-field",
          "static-method",
          "instance-method"
        ]
      }
    ],
    "no-consecutive-blank-lines": false,
    "no-console": [
      true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-empty": false,
    "no-inferrable-types": [
      true,
      "ignore-params"
    ],
    "no-non-null-assertion": true,
    "no-redundant-jsdoc": true,
    "no-switch-case-fall-through": true,
    "no-var-requires": false,
    "object-literal-key-quotes": [
      true,
      "as-needed"
    ],
    "object-literal-sort-keys": false,
    "ordered-imports": false,
    "quotemark": [
      true,
      "single"
    ],
    "semicolon": {
      "options": [
        "always"
      ]
    },
    "space-before-function-paren": {
      "options": {
        "anonymous": "never",
        "asyncArrow": "always",
        "constructor": "never",
        "method": "never",
        "named": "never"
      }
    },
    "trailing-comma": false,
    "no-conflicting-lifecycle": true,
    "no-host-metadata-property": false,
    "no-input-rename": true,
    "no-inputs-metadata-property": true,
    "no-output-native": true,
    "no-output-on-prefix": true,
    "no-output-rename": true,
    "no-outputs-metadata-property": true,
    "template-banana-in-box": true,
    "template-no-negated-async": true,
    "typedef-whitespace": {
      "options": [
        {
          "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"
        }
      ]
    },
    "use-lifecycle-interface": true,
    "use-pipe-transform-interface": true,
    "variable-name": {
      "options": [
        "allow-pascal-case",
        "allow-leading-underscore"
      ]
    },
    "whitespace": {
      "options": [
        "check-branch",
        "check-decl",
        "check-operator",
        "check-separator",
        "check-type",
        "check-typecast"
      ]
    }
  },
  "rulesDirectory": [
    "codelyzer"
  ]
}

我不能确定,因为我没有 Webstorm 编辑器但是找到了这个 link

在 Webstorm 设置中添加导入和大括号之间的空格:

  1. 打开设置:文件 > 默认设置
  2. 展开左侧的编辑器菜单
  3. 在编辑器菜单下展开代码样式菜单
  4. 如果您使用的是 TypeScript,请单击 JavaScript 或 TypeScript
  5. 单击右侧内容区域中的空间选项卡
  6. 向下滚动到设置内
  7. Select ES6 import/export 大括号
  8. 点击应用并确定关闭