TSLint与VS代码格式文档的冲突

问题描述 投票:0回答:1

您能否告诉我如何解决TSLint和VS代码格式文档问题?即TsLint格式设置规则和VS代码文档格式可做两件事。

这里是关于该冲突的YouTube视频:https://youtu.be/1MoUX8BdO9E

enter image description here

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个回答
0
投票

这里有两件事:

1)确实不建议再使用tslint。实际上,它几乎是deprecated and should be replaced by ESLint.

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

© www.soinside.com 2019 - 2024. All rights reserved.