eslint-plugin-sort-class-members icon indicating copy to clipboard operation
eslint-plugin-sort-class-members copied to clipboard

Support to match methods/properties by keywords instead of name

Open fabio-bertone opened this issue 5 years ago • 1 comments

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 }
}

fabio-bertone avatar Jul 16 '20 13:07 fabio-bertone

No objection here! I don't have bandwidth to add this myself, but I'd be happy to take a PR for it.

bryanrsmith avatar Jul 20 '20 15:07 bryanrsmith