Typescript 在tslint.json的配置中包括什么?

Typescript 在tslint.json的配置中包括什么?,typescript,tslint,Typescript,Tslint,我不知道哪个规则应该包含在tslint.json中。有谁能告诉我tslint.json的常用或标准用法吗 如何编写tslint.json文件 如何编写tslint.json文件 文件: 下面是一个示例tslint.json: 您将只使用您关心的规则: 例如,小样本: { "rules": { "no-unreachable": true } } 派对迟到了,但这可能会对其他人有所帮助,所以我只想发表评论。json为干净代码和多个自定义选项(如使用自定义引号、自定

我不知道哪个规则应该包含在
tslint.json
中。有谁能告诉我
tslint.json
的常用或标准用法吗

如何编写tslint.json文件

如何编写tslint.json文件

文件:

下面是一个示例
tslint.json

您将只使用您关心的规则:

例如,小样本:

{
    "rules": {
        "no-unreachable": true
    }
}

派对迟到了,但这可能会对其他人有所帮助,所以我只想发表评论。json为干净代码和多个自定义选项(如使用自定义引号、自定义缩进等)提供了更好的配置。我的带有Angular 8的tslint如下所示,您可以将其用作参考:

{
  "rulesDirectory": [
  "node_modules/codelyzer"
  ],
  "rules": {
    "callable-types": true,
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "curly": true,
    "eofline": true,
    "forin": true,
    "import-blacklist": [true],
    "import-spacing": true,
    "indent": [
      true,
      "spaces"
    ],
    "interface-over-type-literal": true,
    "label-position": true,
    "max-line-length": [
      true,
      140
    ],
    "member-access": false,
    "member-ordering": [
      true,
      "static-before-instance",
      "variables-before-functions"
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-empty-interface": true,
    "no-eval": true,
    "no-inferrable-types": [true, "ignore-params"],
    "no-shadowed-variable": true,
    "no-string-literal": false,
    "no-string-throw": true,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": true,
    "no-unused-expression": true,
    "no-use-before-declare": true,
    "no-var-keyword": true,
    "object-literal-sort-keys": false,
    "one-line": [
      true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "prefer-const": true,
    "quotemark": [
      true,
      "single"
    ],
    "radix": true,
    "semicolon": [
      "always"
   ],
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "typeof-compare": true,
    "unified-signatures": true,
    "variable-name": false,
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],

    "directive-selector": [true, "attribute", "app", "camelCase"],
    "component-selector": [true, "element", "app", "kebab-case"],
    "use-input-property-decorator": true,
    "use-output-property-decorator": true,
    "use-host-property-decorator": true,
    "no-input-rename": true,
    "no-output-rename": true,
    "use-life-cycle-interface": true,
    "use-pipe-transform-interface": true,
    "component-class-suffix": true,
    "directive-class-suffix": true,
    "no-access-missing-member": true,
    "templates-use-public": true,
    "invoke-injectable": true
  }
}

配置它取决于您想要实现的目标。您可以使用tsc生成一个默认值--init@toskv您可能是指
tslint--init
。我不确定示例配置的功能质量。你也可以试试看。请注意,TypeScript使用了一些自定义规则,因此您还需要从他们的回购协议中获取这些规则,或者从配置中删除它们。
下面是一个直接来自文档的示例:https://github.com/palantir/tslint/blob/master/docs/sample.tslint.json
->链接已断开:/