TSLint member-ordering
Asked Answered
I

1

5

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

Impassible answered 17/10, 2018 at 19:34 Comment(4)
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.Shears
Thanks for the clarification, I'll take some times reading the doc (though I hope that I won't have to reorder the code in my methods and only the tslint.json)Impassible
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.Shears
I do know that, however switching from typescrypt 2.9 to 3.1 added these warnings. My bad though, I should have read the documentation more thoroughlyImpassible
S
12

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"
        ]
    }
],
Shears answered 17/10, 2018 at 19:54 Comment(1)
I'll have to do some modifications on it but thank you very much for your answer, now I know what I should search. Thank you for your timeImpassible

© 2022 - 2024 — McMap. All rights reserved.