Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 322
L. Faros Avatar asked Dec 17 '22 20:12

L. Faros


1 Answers

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"
        ]
    }
],
like image 122
axiac Avatar answered Dec 28 '22 10:12

axiac