Skip to content

Commit

Permalink
feat(rules): add no-multiple-empty-lines rule
Browse files Browse the repository at this point in the history
This prevents multiple empty/blank lines, which comes up semi-often
in code review

Ref: LOG-9871
  • Loading branch information
mdeltito committed May 31, 2021
1 parent 3260eaf commit 29a8c68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
}],
"no-loop-func": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multiple-empty-lines": [2, {"max": 1}],
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 0,
Expand Down
13 changes: 13 additions & 0 deletions test/failures.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ test('Invalid linting for larger code blocks read from fixtures', async (t) => {
)
})

t.test('no-multiple-empty-lines', async (t) => {
const result = cli.executeOnFiles(['no-multiple-empty-lines-fixture'])
t.equal(result.errorCount, 1, 'error count')
const messages = result.results[0].messages

t.equal(messages[0].ruleId, 'no-multiple-empty-lines', 'multiple empty found')
t.match(
messages[0].message
, /more than 1 blank line not allowed/ig
, 'message expected multiple empty'
)
})

t.test('no-debugger', async (t) => {
const result = cli.executeOnFiles(['no-debugger-fixture'])
t.equal(result.errorCount, 1, 'error count')
Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/no-multiple-empty-lines-fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'

module.exports = fooBar


function fooBar() {
return true
}

0 comments on commit 29a8c68

Please sign in to comment.