chinchiheather / tslint-lines-between-class-members

Custom rule for TSLint to enforce blank lines between class methods - achieves a similar thing to lines-between-class-members in ESLint
18 stars 5 forks source link

Bug: Expects blank line at overloading #17

Open Xenya0815 opened 5 years ago

Xenya0815 commented 5 years ago

Used versions

Code

class X {
  foo(x: number, y: string): string;
  foo( y: string): number;
  foo(...args: any): string | number {
    return 42;
  }
}

Expected behavior No error

Actual behavior It wants to have a blank line between the function declarations.

fix changes it to

class X {
  foo(x: number, y: string): string;

  foo( y: string): number;

  foo(...args: any): string | number {
    return 42;
  }
}
chinchiheather commented 5 years ago

Hi @Xenya0815 , sorry for the late reply... If this is still an issue for you, can I ask if you have configured the rule to have 0 lines?

Xenya0815 commented 5 years ago

hi @chinchiheather yes it is still a blocker why we can't use that rule :-(

I configured it to 1 line. I want to have 1 line between different members but between the different declarations of an overloaded method I want to have 0 lines. I think my example from the topic is easier to understand if I add an additional class member:

expected behavior with configuration "lines-between-class-members": [true, 1]

class X {
  bar() {
    return 'hello world';
  }

  foo(x: number, y: string): string;
  foo( y: string): number;
  foo(...args: any): string | number {
    return 42;
  }
}
chinchiheather commented 5 years ago

Hmm okay, yeah I understand what you are after now.

I think this might be a bit too niche for me to implement right now, but I will be open to accepting pull requests if anyone else wants to work on it.