Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit b54acbe

Browse files
committed
Fix: don't throw on empty block with "requirePaddingNewLinesAfterBlocks"
Fixes #1952
1 parent b293d92 commit b54acbe

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/rules/require-padding-newlines-after-blocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function isException(parent, exceptions) {
131131
var grandpa = parent.parentNode;
132132

133133
// Check if this block is used in call or array expression
134-
if (exceptions[grandpa.type]) {
134+
if (grandpa && exceptions[grandpa.type]) {
135135
return true;
136136
}
137137

test/specs/rules/require-padding-newlines-after-blocks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ describe('rules/require-padding-newlines-after-blocks', function() {
1010
checker.registerDefaultRules();
1111
});
1212

13+
it('should not throw expections with blocks', function() {
14+
checker.configure({ requirePaddingNewLinesAfterBlocks: true });
15+
expect(checker.checkString('{}')).to.have.no.errors();
16+
});
17+
1318
describe('invalid options', function() {
1419
it('should throw if empty object', function() {
1520
expect(function() {

0 commit comments

Comments
 (0)