Skip to content

Commit

Permalink
lines-between-class-members
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekkopecky authored and ear1grey committed Mar 27, 2020
1 parent 7a9b0ff commit 78b5eba
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ module.exports = {
asyncArrow: 'always',
}],
'quotes': ['error', 'single', 'avoid-escape'],
'lines-between-class-members': ['error', 'always', {
exceptAfterSingleLine: true,
}],
},
};
11 changes: 11 additions & 0 deletions tests/files/lines-between-class-members-bad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Example {
constructor() {
console.log();
}
// there should be a line between class members
method() {
console.log();
}
}

console.log((new Example()).theAnswer);
16 changes: 16 additions & 0 deletions tests/files/lines-between-class-members-good.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Example {
constructor() {
console.log();
}

// no line between one-line class members is OK
get theAnswer() { return 42; }
get message() { return 'hi'; }

// method() is unused but sadly the linter doesn't catch it yet
method() {
console.log();
}
}

console.log((new Example()).theAnswer);

0 comments on commit 78b5eba

Please sign in to comment.