Skip to content

lines-between-class-members & class field declarations #1347

@swansontec

Description

@swansontec

What version of standard?

v13

What did you expect to happen?

The new lines-between-class-members rule is great, since putting spaces between member functions is an obvious code cleanup. However, the class fields stage 3 proposal, Typescript, and Flow all add the concept of class member variables to the mix. They look something like this:

class DataMuncher {
  // Work:
  pendingItems = []
  finishedItems = []

  // Scheduling:
  started: boolean = false
  stopped: boolean = false
  timeoutId = null

  constructor () { ... }

  someMethod () { ... }
}

What actually happened?

With the new rule, Standard now insists on spaces between the class field declarations:

class DataMuncher {
  // Work:
  pendingItems = []

  finishedItems = []

  // Scheduling:
  started: boolean = false

  stopped: boolean = false

  timeoutId = null

  constructor () { ... }

  someMethod () { ... }
}

This is a clear readability loss.

This mainly affects shareable config users, since Standard doesn't support class field declarations out-of-the-box. Adding the "exceptAfterSingleLine": true option to this eslint rule would help users who use Standard.js along with this experimental / non-standard feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions