Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts/lines-between-class-members: does not apply to interface members #352

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ygrandgirard
Copy link

@ygrandgirard ygrandgirard commented Apr 17, 2024

Description

PR with failing test for issue #353.
The ts/lines-between-class-members rule does not apply to interface members.

Given this config:

{
  "rules": {
    "@stylistic/ts/lines-between-class-members": "error"
  }
}

This will be reported:

class A {
  a: string;
  b: string; // Expected blank line between class members.
}

But not this:

interface A {
  a: string;
  b: string;
}

Linked Issues

#353

Additional context

It does not look particularly difficult to fix (see ygrandgirard/eslint-stylistic@main...ygrandgirard:eslint-stylistic:bugfix/lines-between-interface-members) though I am not sure about the typing. If you are ok, I can create another PR with my fix.

@antfu
Copy link
Member

antfu commented Apr 29, 2024

I don't understand - the rule name is specifically mention it's for class-members - I don't think lint for interface making sense.

@ygrandgirard
Copy link
Author

The way I see TypeScript interfaces is as syntactic sugar around abstract classes. Maybe I am wrong in doing so, I don't know how the compiler actually treats them. But still, it totally makes sense to me that this rule handles both.
However, I understand that my point of view may not be shared by everyone. If you think a separate rule should be better, I can open another PR for that instead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ts/lines-between-class-members: does not apply to interface members
2 participants