question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposed Rule: Enforce lines between class methods

See original GitHub issue

I would like to propose a rule that enforces empty lines between class functions. When enabled and set to “always” it should make sure that there is at least one empty line between every method in a class declaration. If set to “never” the opposite would be true, that is, there should not be any empty lines at all between class methods.

A line with a comment on should not count as an empty line.

This rule should not concern itself with the class padding (empty lines before the first method and after the last method) since that is already taken care of by padded-blocks.

It also shouldn’t concern itself with how many empty lines that are present, since that is a job for no-multiple-empty-lines.

This is a stylistic rule.

The following patterns would be considered problems:

class Test1 {
  constructor () {
    // ...
  }
  otherFunc () {
    // ...
  }
}

class Test2 {
  constructor () {
    // ...
  }
  // comment
  otherFunc () {
    // ...
  }
}

The following pattern would be considered valid:

class Test3 {
  constructor () {
    // ...
  }

  otherFunc () {
    // ...
  }
}

class Test4 {
  constructor () {
    // ...
  }



  otherFunc () {
    // ...
  }
}

class Test5 {
  constructor () {
    // ...
  }

  // comment
  otherFunc () {
    // ...
  }
}

class Test6 {
  constructor () {
    // ...
  }

  // Comment

  otherFunc () {
    // ...
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:34
  • Comments:59 (40 by maintainers)

github_iconTop GitHub Comments

5reactions
TheSaviorcommented, Sep 26, 2016

What is the status of this issue?

I’m happy to help contribute to this to push it over the finish line. I wrote the JSCS rule this is discussing and this is one of the last rules left in my company’s conversion from JSCS to eslint.

4reactions
aladdin-addcommented, Aug 22, 2017

I‘ll work on this, perhaps this weekend.😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

lines-between-class-members - Pluggable JavaScript Linter
This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the...
Read more >
lines-between-class-members | typescript-eslint
This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the...
Read more >
require or disallow an empty line between ... - Breword 文档集合
This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the...
Read more >
Require or disallow an empty line between class members ...
This rule improves readability by enforcing lines between class members. ... It adds support for ignoring overload methods in a class.
Read more >
"lines-between-class-members" ESLint Error When Declaring ...
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 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found