eslint-plugin-sort-class-members
eslint-plugin-sort-class-members copied to clipboard
Support to match methods/properties by keywords instead of name
Currently there are no rules that cover methods used with private, public keywords in TS. I'd like the feature to sort public methods before private methods without having to use underscore as a prefix for private names.
I'm proposing a rule that looks at the keyword used to order properties and methods in a class.
This should pass with the order
[
"[static-properties]",
"[static-methods]",
"[properties]",
"[private-properties]", //new
"constructor",
"[methods]",
"[private-methods]" //new
]
class Foo {
public bar = 'Im a public string';
baz = 'Im also a public string';
private foobar = 'Im a private string';
someMethod() { //public }
public somePublicMethod() { //public }
private somePrivateMethod() { //private }
}
No objection here! I don't have bandwidth to add this myself, but I'd be happy to take a PR for it.