Skip to content

Linting fails for constructor of generic type after prettier multi-line format #13

@seangwright

Description

@seangwright

Prettier formats some generic type definitions by placing the generic constraints on multiple lines.

This causes tslint-lines-between-class-members to fail linting.

The error is must have 1 new line(s) between class methods, see docs for how to configure which appears on the constructor() { line.

I believe this is due to how you are checking the previous line.

Passes

export class PermissionsStore extends EntityStore<PermissionsState, Permission> {
  constructor() {
    super();
  }
}

Fails

export class PermissionsStore extends EntityStore<
  PermissionsState,
  Permission
> {
  constructor() {
    super();
  }
}

I also ran into this situation where Prettier puts the implements keyword on its own line which causes this lint rule to fail at the line constructor() { }.

interface SomeInterface {
    name: string;
}

export class SomeClass
  implements SomeInterface {
  constructor() { }

  name = 'test';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions