From 0d58a24f688dcbd0e0c82589562d67513d96557c Mon Sep 17 00:00:00 2001 From: Rafael Santana Date: Sat, 11 Sep 2021 21:29:22 -0300 Subject: [PATCH] fix(eslint-plugin): [padding-line-between-statements] problems within namespaces not being reported --- .../rules/padding-line-between-statements.ts | 3 +- .../padding-line-between-statements.test.ts | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/padding-line-between-statements.ts b/packages/eslint-plugin/src/rules/padding-line-between-statements.ts index f686476e5de..2da4042fbf0 100644 --- a/packages/eslint-plugin/src/rules/padding-line-between-statements.ts +++ b/packages/eslint-plugin/src/rules/padding-line-between-statements.ts @@ -723,10 +723,11 @@ export default util.createRule({ if ( !node.parent || ![ - AST_NODE_TYPES.SwitchStatement, AST_NODE_TYPES.BlockStatement, AST_NODE_TYPES.Program, AST_NODE_TYPES.SwitchCase, + AST_NODE_TYPES.SwitchStatement, + AST_NODE_TYPES.TSModuleBlock, ].includes(node.parent.type) ) { return; diff --git a/packages/eslint-plugin/tests/rules/padding-line-between-statements.test.ts b/packages/eslint-plugin/tests/rules/padding-line-between-statements.test.ts index d018f189929..c55a85de08b 100644 --- a/packages/eslint-plugin/tests/rules/padding-line-between-statements.test.ts +++ b/packages/eslint-plugin/tests/rules/padding-line-between-statements.test.ts @@ -5056,5 +5056,45 @@ var a = 1 { messageId: 'expectedBlankLine' }, ], }, + { + // https://github.com/typescript-eslint/typescript-eslint/issues/3863 + code: ` +declare namespace Types { + type Foo = string; + type Bar = string; + interface FooBar { + [key: string]: string; + } + interface BarBaz { + [key: string]: string; + } +} + `, + output: ` +declare namespace Types { + type Foo = string; + + type Bar = string; + + interface FooBar { + [key: string]: string; + } + + interface BarBaz { + [key: string]: string; + } +} + + `, + options: [ + { blankLine: 'always', prev: '*', next: ['interface', 'type'] }, + ], + errors: [ + { messageId: 'expectedBlankLine' }, + { messageId: 'expectedBlankLine' }, + { messageId: 'expectedBlankLine' }, + { messageId: 'expectedBlankLine' }, + ], + }, ], });