"lines-between-class-members" ESLint Error When Declaring Class Properties

Viewed 5464

As I like the "lines-between-class-members" rule, I'd like to enforce spaces between my classes' functions, but in the same time I want the properties declarations packed at the beginning of my classes in the following format:

class Foo {
  a: number;
  b: number;
  c: string;
  d: string;

  constructor() {
    // constructor stuff
  }

  doSomething() {
    // do something
  }
}

Is there a way to ignore this rule specifically on types declarations?

3 Answers

It seems like you'll have to do this

'lines-between-class-members': [
  'error',
  'always',
  { 'exceptAfterSingleLine': true },
]

Docs It will skips checks for empty lines after a single-line class member.

Please add this hopefully it will work:

/* eslint-disable no-trailing-spaces */

Related