Skip to content

Commit

Permalink
Update: Fix 'function' in padding-line-between-statements (fixes #10487
Browse files Browse the repository at this point in the history
…) (#10676)
  • Loading branch information
platinumazure committed Jul 28, 2018
1 parent c2bb8bb commit f026fe1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/padding-line-between-statements.js
Expand Up @@ -367,6 +367,7 @@ const StatementTypes = {

block: newNodeTypeTester("BlockStatement"),
empty: newNodeTypeTester("EmptyStatement"),
function: newNodeTypeTester("FunctionDeclaration"),

break: newKeywordTester("break"),
case: newKeywordTester("case"),
Expand All @@ -378,7 +379,6 @@ const StatementTypes = {
do: newKeywordTester("do"),
export: newKeywordTester("export"),
for: newKeywordTester("for"),
function: newKeywordTester("function"),
if: newKeywordTester("if"),
import: newKeywordTester("import"),
let: newKeywordTester("let"),
Expand Down
18 changes: 17 additions & 1 deletion tests/lib/rules/padding-line-between-statements.js
Expand Up @@ -19,7 +19,7 @@ const RuleTester = require("../../../lib/testers/rule-tester");
const MESSAGE_NEVER = "Unexpected blank line before this statement.";
const MESSAGE_ALWAYS = "Expected blank line before this statement.";

const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2015 } });
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2017 } });

ruleTester.run("padding-line-between-statements", rule, {
valid: [
Expand Down Expand Up @@ -811,6 +811,13 @@ ruleTester.run("padding-line-between-statements", rule, {
{ blankLine: "always", prev: "function", next: "*" }
]
},
{
code: "async function foo(){}\n\nfoo()",
options: [
{ blankLine: "never", prev: "*", next: "*" },
{ blankLine: "always", prev: "function", next: "*" }
]
},

//----------------------------------------------------------------------
// if
Expand Down Expand Up @@ -3317,6 +3324,15 @@ ruleTester.run("padding-line-between-statements", rule, {
],
errors: [MESSAGE_ALWAYS]
},
{
code: "async function foo(){}\nfoo()",
output: "async function foo(){}\n\nfoo()",
options: [
{ blankLine: "never", prev: "*", next: "*" },
{ blankLine: "always", prev: "function", next: "*" }
],
errors: [MESSAGE_ALWAYS]
},

//----------------------------------------------------------------------
// if
Expand Down

0 comments on commit f026fe1

Please sign in to comment.