【问题标题】:Conflict of TSLint and VS code Format DocumentTSLint 和 VS code 格式文档冲突
【发布时间】:2020-02-16 08:32:26
【问题描述】:

你能告诉我如何解决这个 TSLint 和 VS 代码格式文档问题吗?即 TsLint 格式化规则和 VS code 文档格式做两件事。

这是有关该冲突的 Youtube 视频:https://youtu.be/1MoUX8BdO9E

tslint.json

{
  "extends": "tslint:recommended",
  "rulesDirectory": [
    "codelyzer"
  ],
  "rules": {
    "array-type": false,
    "arrow-parens": false,
    "deprecation": {
      "severity": "warn"
    },
    "import-blacklist": [
      true,
      "rxjs/Rx"
    ],
    "interface-name": false,
    "max-classes-per-file": false,
    "max-line-length": [
      true,
      200
    ],
    "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-use-before-declare": true,
    "no-var-requires": false,
    "object-literal-key-quotes": [
      true,
      "as-needed"
    ],
    "object-literal-sort-keys": false,
    "ordered-imports": false,
    "quotemark": [
      true,
      "single"
    ],
    "trailing-comma": false,
    "no-output-on-prefix": true,
    "no-inputs-metadata-property": true,
    "no-host-metadata-property": true,
    "no-input-rename": true,
    "no-output-rename": true,
    "use-lifecycle-interface": true,
    "use-pipe-transform-interface": true,
    "one-variable-per-declaration": false,
    "component-class-suffix": [
      true,
      "Page",
      "Component"
    ],
    "directive-class-suffix": true,
    "directive-selector": [
      true,
      "attribute",
      "app",
      "camelCase"
    ],
    "component-selector": [
      true,
      "element",
      "app",
      "page",
      "kebab-case"
    ]
  }
}

【问题讨论】:

    标签: typescript visual-studio-code tslint


    【解决方案1】:

    我能够像这样解决这个问题:即你可以看到所有的新行。

    constructor(
        private router: Router,
        private modalController: ModalController,
        public detectBackendService: DetectBackendService,
        private formBuilder: FormBuilder,
        public departmentsDataService: DepartmentsDataService,
    
      ) { }
    

    【讨论】:

      【解决方案2】:

      这里有两件事:

      1) 真的不再推荐使用 tslint。其实差不多就是deprecated and should be replaced by ESLint.

      2) 我建议集成 Prettier 而不是使用 VSCode 的默认格式化程序。 Prettier can work with ESLint 以确保格式一致而不会出现冲突错误。

      【讨论】:

      • 但是由于 TSLint 是 Ionic 4 应用程序的默认设置,我该如何迁移到 ESLint?
      • 我真的不喜欢 Prettier,因为它有很多丑陋的格式。我喜欢 VS 代码默认的 Format Document 选项。
      猜你喜欢
      • 2020-09-26
      • 2020-07-24
      • 2019-11-28
      • 2018-07-22
      • 2019-10-29
      • 2020-03-23
      • 1970-01-01
      • 2022-01-02
      • 2018-09-09
      相关资源
      最近更新 更多