Skip to content

Commit

Permalink
Fix: padding-line-between-statements crash on semicolons after blocks (
Browse files Browse the repository at this point in the history
…#8748)

(fixes #8839)
  • Loading branch information
madyankin authored and not-an-aardvark committed Jul 30, 2017
1 parent 3141872 commit cdb82f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/padding-line-between-statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function isBlockLikeStatement(sourceCode, node) {

// Checks the last token is a closing brace of blocks.
const lastToken = sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
const belongingNode = astUtils.isClosingBraceToken(lastToken)
const belongingNode = lastToken && astUtils.isClosingBraceToken(lastToken)
? sourceCode.getNodeByRangeIndex(lastToken.range[0])
: null;

Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/padding-line-between-statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,12 @@ ruleTester.run("padding-line-between-statements", rule, {
options: [
{ blankLine: "always", prev: "*", next: ["if", "for", "return", "switch", "case", "break", "throw", "while", "default"] }
]
},
{
code: "function test() {};",
options: [
{ blankLine: "always", prev: "block-like", next: "block-like" }
]
}
],
invalid: [
Expand Down

0 comments on commit cdb82f2

Please sign in to comment.