Skip to content

Commit

Permalink
prefer-default-export: don't warn on TypeAlias & TSTypeAliasDeclaration
Browse files Browse the repository at this point in the history
Fixes #1332.
  • Loading branch information
sharmilajesupaul committed Jul 17, 2019
1 parent 15e5c61 commit adf4aaa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ 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
21 changes: 21 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,27 @@ ruleTester.run('prefer-default-export', rule, {
parser: 'babel-eslint',
}),

// Exporting types
test({
code: `
export type foo = string;
export type bar = number;`,
parser: 'typescript-eslint-parser',
}),
test({
code: `
export type foo = string;
export type bar = number;`,
parser: 'babel-eslint',
}),
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 adf4aaa

Please sign in to comment.