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. Remove the check for `node.exportKind` as it is `undefined` in all test cases.
  • Loading branch information
sharmilajesupaul committed Jun 10, 2019
1 parent 15e5c61 commit a686d0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ module.exports = {
// if there are specifiers, node.declaration should be null
if (!node.declaration) return

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

if (node.declaration.declarations) {
node.declaration.declarations.forEach(function(declaration) {
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 a686d0e

Please sign in to comment.