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

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

Closed
swansontec opened this issue Aug 2, 2019 · 3 comments

Comments

@swansontec
Copy link

commented Aug 2, 2019

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.

@swansontec swansontec changed the title `lines-between-class-members` & class properties `lines-between-class-members` & class field declarations Aug 2, 2019

@LinusU

This comment has been minimized.

Copy link
Member

commented Aug 2, 2019

Adding exceptAfterSingleLine seems like a good way forward 👍

@feross

This comment has been minimized.

Copy link
Member

commented Aug 4, 2019

Thanks for the suggestion. I agree with your reasoning.

@feross feross closed this in db18da3 Aug 4, 2019

@feross

This comment has been minimized.

Copy link
Member

commented Aug 4, 2019

This will ship in standard v14.

@feross feross added this to the standard v14 milestone Aug 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.