L. Faros
L. Faros

Reputation: 1992

TSLint member-ordering

I have the following rules in my tslint.json :

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

However I still get this warning :

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

Typescrypt version is 3.1.1

Node version is 10.10.0

Upvotes: 5

Views: 15359

Answers (1)

axiac
axiac

Reputation: 72226

As the error message says, the values you put in the order array are not recognized by tslint. Read about member-ordering in the documentation of the member-ordering rule.

You can specify in tslint.json the exact order you want or you can specify only some components (f.e. let the static methods out) and the missing components can stay anywhere in the class.

The following configuration matches the rules you expressed:

"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"
        ]
    }
],

Upvotes: 12

Related Questions