【问题标题】:Get all TsLint rules in tslint.json file获取 tslint.json 文件中的所有 TsLint 规则
【发布时间】:2017-11-20 02:08:21
【问题描述】:

我正在配置SonarTsPlugin,并试图弄清楚在我的 tslint.json 中放入什么(我还没有)。首先,我想启用 SonarQube 中可用的所有 TypeScript 规则。我找到了这个并随机添加到我的项目中:

{
    "jsRules": {
        "class-name": true,
        "comment-format": [
            true,
            "check-space"
        ],
        "indent": [
            true,
            "spaces"
        ],
        "no-duplicate-variable": true,
        "no-eval": true,
        "no-trailing-whitespace": true,
        "no-unsafe-finally": true,
        "one-line": [
            true,
            "check-open-brace",
            "check-whitespace"
        ],
        "quotemark": [
            true,
            "double"
        ],
        "semicolon": [
            true,
            "always"
        ],
        "triple-equals": [
            true,
            "allow-null-check"
        ],
        "variable-name": [
            true,
            "ban-keywords"
        ],
        "whitespace": [
            true,
            "check-branch",
            "check-decl",
            "check-operator",
            "check-separator",
            "check-type"
        ]
    },
    "rules": {
        "class-name": true,
        "comment-format": [
          true,
          "check-space"
        ],
        "curly": true,
        "indent": [
            true,
            "spaces"
        ],
        "no-eval": true,
        "no-internal-module": true,
        "no-trailing-whitespace": true,
        "no-unsafe-finally": true,
        "no-var-keyword": true,
        "one-line": [
            true,
            "check-open-brace",
            "check-whitespace"
        ],
        "quotemark": [
            true,
            "double"
        ],
        "semicolon": [
            true,
            "always"
        ],
        "triple-equals": [
            true,
            "allow-null-check"
        ],
        "typedef-whitespace": [
            true,
            {
                "call-signature": "nospace",
                "index-signature": "nospace",
                "parameter": "nospace",
                "property-declaration": "nospace",
                "variable-declaration": "nospace"
            }
        ],
        "variable-name": [
            true,
            "ban-keywords"
        ],
        "whitespace": [
            true,
            "check-branch",
            "check-decl",
            "check-operator",
            "check-separator",
            "check-type"
        ]
    }
}

TypeScript 插件与它配合得很好,但我不确定它是否启用所有可能的规则。有没有人有一个 tslint.json 的例子呢?谢谢。

注意:我启动了tsc --init 命令来生成默认配置文件,但我问自己同样的问题。在 SonarQube 中,我看到有 100 多个规则,但文件仅包含 ~50。

【问题讨论】:

    标签: typescript sonarqube tslint


    【解决方案1】:

    您可以找到 TSLint in their official documentation 支持的完整规则列表

    【讨论】:

    • 好吧,这很方便。所以不可能,例如,从 SonarQube 配置生成一个 tslint.json 文件?这太糟糕了,我觉得在 SonarQube 中同时拥有 TypeScript 质量配置文件和项目中的自定义配置有点混乱。我想知道为什么它是这样实现的。
    猜你喜欢
    • 2020-12-31
    • 2017-06-16
    • 2017-05-14
    • 2020-02-26
    • 1970-01-01
    • 2018-04-12
    • 2020-07-24
    • 2017-11-25
    • 1970-01-01
    相关资源
    最近更新 更多