Skip to content

Commit

Permalink
Fixes 1332
Browse files Browse the repository at this point in the history
Skips warning on a single type declaration or type alias.
  • Loading branch information
sharmilajesupaul committed Jun 10, 2019
1 parent 15e5c61 commit 382b26c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ module.exports = {
// if there are specifiers, node.declaration should be null
if (!node.declaration) return

// don't count flow types exports
// don't warn on single type aliases or declarations
if (node.exportKind === 'type') return

if(node.declaration.type === 'TSTypeAliasDeclaration'
|| node.declaration.type === 'TypeAlias') return

if (node.declaration.declarations) {
node.declaration.declarations.forEach(function(declaration) {
captureDeclaration(declaration.id)
Expand Down
10 changes: 10 additions & 0 deletions tests/src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ ruleTester.run('prefer-default-export', rule, {
parser: 'babel-eslint',
}),

// Single type declaration
test({
code: 'export type foo = string',
parser: 'typescript-eslint-parser',
}),
test({
code: 'export type foo = string',
parser: 'babel-eslint',
}),

// ...SYNTAX_CASES,
],
invalid: [
Expand Down

0 comments on commit 382b26c

Please sign in to comment.