TSLint会员订购

时间:2018-10-17 19:34:04

标签: typescript tslint

我在tslint.json中具有以下规则:

    "member-ordering": [
        true,
        {
            "order": [
                "public-before-private",
                "static-before-instance",
                "variables-before-functions"
            ]
        }
    ],

但是我仍然收到此警告:

Warning: member-ordering - Bad member kind: public-before-private

Typescrypt版本为3.1.1

节点版本为10.10.0

1 个答案:

答案 0 :(得分:3)

如错误消息所述,tslint无法识别您放置在order数组中的值。在documentation of the member-ordering rule中了解member-ordering

您可以在tslint.json中指定所需的确切顺序,也可以仅指定某些组件(例如,释放静态方法),而缺少的组件可以保留在类中的任何位置。

以下配置符合您表达的规则:

"member-ordering": [
    true,
    {
        "order": [
            "public-static-field",
            "public-static-method",
            "public-instance-field",
            "public-constructor",
            "public-instance-method",

            "protected-static-field",
            "protected-static-method",
            "protected-instance-field",
            "protected-constructor",
            "protected-instance-method",

            "private-static-field",
            "private-static-method",
            "private-instance-field",
            "private-constructor",
            "private-instance-method"
        ]
    }
],