Skip to content

Commit

Permalink
[bugfix] Skip warning on type interfaces
Browse files Browse the repository at this point in the history
Similar to #1377,
we don't want this rule to apply to exported interfaces.
  • Loading branch information
lencioni committed Jul 19, 2019
1 parent b51aa2f commit 582236b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions tests/src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ context('Typescript', function() {
},
parserConfig,
),
test (
{
code: 'export interface foo { bar: string; }',
parser,
},
parserConfig,
),
],
invalid: [],
});
Expand Down

0 comments on commit 582236b

Please sign in to comment.