Skip to content

Commit

Permalink
fix(eslint-plugin): [padding-line-between-statements] make function o…
Browse files Browse the repository at this point in the history
…verloading is also processed (#4345)
  • Loading branch information
lonyele authored Dec 27, 2021
1 parent 6edebcd commit d31ec26
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,9 @@ export default util.createRule<Options, MessageIds>({
':statement': verify,

SwitchCase: verifyThenEnterScope,
TSDeclareFunction: verifyThenEnterScope,
'SwitchCase:exit': exitScope,
'TSDeclareFunction:exit': exitScope,
};
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,20 @@ var a = 1
{ blankLine: 'always', prev: 'block-like', next: 'block-like' },
],
},
{
code: 'export function foo(arg1: string): number;\nexport function foo(arg2: number) {\n return arg2;\n}',
options: [
{ blankLine: 'always', prev: '*', next: 'block-like' },
{ blankLine: 'never', prev: '*', next: 'export' },
],
},
{
code: 'function foo(arg1: string): number;\nfunction foo(arg2: number) {\n return arg2;\n}',
options: [
{ blankLine: 'always', prev: '*', next: 'block-like' },
{ blankLine: 'never', prev: '*', next: 'function' },
],
},
],
invalid: [
//----------------------------------------------------------------------
Expand Down Expand Up @@ -5101,5 +5115,19 @@ declare namespace Types {
{ messageId: 'expectedBlankLine' },
],
},
{
code: 'export function foo(arg1: string): number;\nexport function foo(arg2: number) {\n return arg2;\n}',
output:
'export function foo(arg1: string): number;\n\nexport function foo(arg2: number) {\n return arg2;\n}',
options: [{ blankLine: 'always', prev: '*', next: 'block-like' }],
errors: [{ messageId: 'expectedBlankLine' }],
},
{
code: 'function foo(arg1: string): number;\nfunction foo(arg2: number) {\n return arg2;\n}',
output:
'function foo(arg1: string): number;\n\nfunction foo(arg2: number) {\n return arg2;\n}',
options: [{ blankLine: 'always', prev: '*', next: 'block-like' }],
errors: [{ messageId: 'expectedBlankLine' }],
},
],
});

0 comments on commit d31ec26

Please sign in to comment.