Skip to content

Commit

Permalink
fix(padding-line-between-statements): recognize ExportAllDeclaration …
Browse files Browse the repository at this point in the history
…nodes (#257)

* fix(padding-line-between-statements): recognize ExportAllDeclaration nodes

* chore: update

* chore: add comments

---------

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
fasttime and antfu committed Jan 8, 2024
1 parent 59070ae commit 52f0506
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,15 @@ ruleTester.run('padding-line-between-statements', rule, {
],
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
},
// https://github.com/eslint-stylistic/eslint-stylistic/pull/257
{
code: 'var a = 0; export * from "foo"\n\nbar()',
options: [
{ blankLine: 'never', prev: '*', next: '*' },
{ blankLine: 'always', prev: 'export', next: '*' },
],
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
},

// ----------------------------------------------------------------------
// for
Expand Down Expand Up @@ -3571,6 +3580,16 @@ ruleTester.run('padding-line-between-statements', rule, {
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
errors: [{ messageId: 'expectedBlankLine' }],
},
// https://github.com/eslint-stylistic/eslint-stylistic/pull/257
{
code: 'var a = 0;export * from "foo"\nbar()',
output: 'var a = 0;export * from "foo"\n\nbar()',
options: [
{ blankLine: 'always', prev: 'export', next: '*' },
],
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
errors: [{ messageId: 'expectedBlankLine' }],
},

// ----------------------------------------------------------------------
// for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,15 @@ ruleTester.run('padding-line-between-statements', rule, {
],
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
},
// https://github.com/eslint-stylistic/eslint-stylistic/pull/257
{
code: 'var a = 0; export * from "foo"\n\nbar()',
options: [
{ blankLine: 'never', prev: '*', next: '*' },
{ blankLine: 'always', prev: 'export', next: '*' },
],
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
},

// ----------------------------------------------------------------------
// for
Expand Down Expand Up @@ -3530,6 +3539,14 @@ var a = 1
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
errors: [{ messageId: 'expectedBlankLine' }],
},
// https://github.com/eslint-stylistic/eslint-stylistic/pull/257
{
code: 'var a = 0;export * from "foo"\nbar()',
output: 'var a = 0;export * from "foo"\n\nbar()',
options: [{ blankLine: 'always', prev: 'export', next: '*' }],
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
errors: [{ messageId: 'expectedBlankLine' }],
},

// ----------------------------------------------------------------------
// for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ const StatementTypes: Record<string, NodeTestObject> = {
'do': newKeywordTester(AST_NODE_TYPES.DoWhileStatement, 'do'),
'export': newKeywordTester(
[
AST_NODE_TYPES.ExportAllDeclaration,
AST_NODE_TYPES.ExportDefaultDeclaration,
AST_NODE_TYPES.ExportNamedDeclaration,
],
Expand Down

0 comments on commit 52f0506

Please sign in to comment.