From 582236be6fd8ff7d7734be50466737190d2190f9 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Fri, 19 Jul 2019 10:55:27 -0700 Subject: [PATCH] [bugfix] Skip warning on type interfaces Similar to https://github.com/benmosher/eslint-plugin-import/pull/1377, we don't want this rule to apply to exported interfaces. --- src/rules/prefer-default-export.js | 10 +++++++--- tests/src/rules/prefer-default-export.js | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/rules/prefer-default-export.js b/src/rules/prefer-default-export.js index 01b8d8be0..59c26d11e 100644 --- a/src/rules/prefer-default-export.js +++ b/src/rules/prefer-default-export.js @@ -47,12 +47,16 @@ module.exports = { // if there are specifiers, node.declaration should be null if (!node.declaration) return - // don't warn on single type aliases or declarations + // don't warn on single type aliases, declarations, or interfaces if (node.exportKind === 'type') return + const { type } = node.declaration + if ( - node.declaration.type === 'TSTypeAliasDeclaration' || - node.declaration.type === 'TypeAlias' + type === 'TSTypeAliasDeclaration' || + type === 'TypeAlias' || + type === 'TSInterfaceDeclaration' || + type === 'InterfaceDeclaration' ) { return } diff --git a/tests/src/rules/prefer-default-export.js b/tests/src/rules/prefer-default-export.js index 5f9645463..ae630b447 100644 --- a/tests/src/rules/prefer-default-export.js +++ b/tests/src/rules/prefer-default-export.js @@ -175,6 +175,13 @@ context('Typescript', function() { }, parserConfig, ), + test ( + { + code: 'export interface foo { bar: string; }', + parser, + }, + parserConfig, + ), ], invalid: [], });