Repository: import-js/eslint-plugin-import (JavaScript)

Issue:
prefer-default-export False Positive
**Description**
`eslint-plugin-import` v2.18.2 throws an error (`error  Prefer default export  import/prefer-default-export`) when there are multiple export statements in a typescript file. (this is probably not limited to typescript)

**Expected Results**
`eslint-plugin-import` v2.18.1 does not throw this error. This behavior aligns with the example page: [prefer-default-export](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md)

**Basic Example:**
```
export interface SubmitHandler {}
export function anything() {}
// error  Prefer default export  import/prefer-default-export
```


Discussion:
Experiencing the same issue with `2.18.1` and above but not with `2.18.0`.
I have the issue with the sapper template. Here is a code sample:

```javascript
import posts from './_posts';

const lookup = new Map();
posts.forEach((post) => {
  lookup.set(post.slug, JSON.stringify(post));
});

export function get(req, res) {
  const { slug } = req.params;

  if (lookup.has(slug)) {
    res.writeHead(200, {
      'Content-Type': 'application/json',
    });

    res.end(lookup.get(slug));
  } else {
    res.writeHead(404, {
      'Content-Type': 'application/json',
    });

    res.end(JSON.stringify({
      message: 'Not found',
    }));
  }
}
```

Is it related to this issue?
@soullivaneuh in that case, you only have a single named export - so the rule is correctly warning, telling you to make it a default export.
So I just have to do something like this?

```javascript
export.default = function get(req, res) {
// ...
```

I don't see any correct match on you examples,

I may open an another issue for that if you want.
No, not like that, like this:
```js
export default function get() {}
```



Patch:
diff --git a/src/rules/prefer-default-export.js b/src/rules/prefer-default-export.js
index f0af00d02b..17a07688c3 100644
--- a/src/rules/prefer-default-export.js
+++ b/src/rules/prefer-default-export.js
@@ -14,6 +14,7 @@ module.exports = {
     let specifierExportCount = 0
     let hasDefaultExport = false
     let hasStarExport = false
+    let hasTypeExport = false
     let namedExportNode = null
 
     function captureDeclaration(identifierOrPattern) {
@@ -50,9 +51,6 @@ module.exports = {
         // if there are specifiers, node.declaration should be null
         if (!node.declaration) return
 
-        // don't warn on single type aliases, declarations, or interfaces
-        if (node.exportKind === 'type') return
-
         const { type } = node.declaration
 
         if (
@@ -61,6 +59,8 @@ module.exports = {
           type === 'TSInterfaceDeclaration' ||
           type === 'InterfaceDeclaration'
         ) {
+          specifierExportCount++
+          hasTypeExport = true
           return
         }
 
@@ -86,7 +86,7 @@ module.exports = {
       },
 
       'Program:exit': function() {
-        if (specifierExportCount === 1 && !hasDefaultExport && !hasStarExport) {
+        if (specifierExportCount === 1 && !hasDefaultExport && !hasStarExport && !hasTypeExport) {
           context.report(namedExportNode, 'Prefer default export.')
         }
       },


Test patch:
diff --git a/tests/src/rules/prefer-default-export.js b/tests/src/rules/prefer-default-export.js
index 452192737f..19aef41e0b 100644
--- a/tests/src/rules/prefer-default-export.js
+++ b/tests/src/rules/prefer-default-export.js
@@ -3,7 +3,7 @@ import { test, getNonDefaultParsers } from '../utils'
 import { RuleTester } from 'eslint'
 
 const ruleTester = new RuleTester()
-    , rule = require('rules/prefer-default-export')
+    , rule = require('../../../src/rules/prefer-default-export')
 
 ruleTester.run('prefer-default-export', rule, {
   valid: [
@@ -194,6 +194,13 @@ context('TypeScript', function() {
           },
           parserConfig,
         ),
+        test (
+          {
+            code: 'export interface foo { bar: string; }; export function goo() {}',
+            parser,
+          },
+          parserConfig,
+        ),
       ],
       invalid: [],
     })