From 29bc56ee2f7ef4bd6a4b6b3cc4d53e56c1154c13 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Thu, 3 Nov 2016 12:11:52 +0100 Subject: [PATCH] Ignoring flow type exports (#639) * Ignoring flow type exports, resolve #484 * Added test and note to CHANGELOG --- CHANGELOG.md | 1 + src/rules/prefer-default-export.js | 3 +++ tests/src/rules/prefer-default-export.js | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92d9103a7..fe177227d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel - [`no-extraneous-dependencies`]: check globs against CWD + absolute path ([#602] + [#630], thanks [@ljharb]) ### Fixed +- [`prefer-default-export`] handles flow `export type` ([#484]) - [`prefer-default-export`] handles re-exported default exports ([#609]) - Fix crash when using [`newline-after-import`] with decorators ([#592]) - Properly report [`newline-after-import`] when next line is a decorator diff --git a/src/rules/prefer-default-export.js b/src/rules/prefer-default-export.js index c1243bf49..fe01adbe2 100644 --- a/src/rules/prefer-default-export.js +++ b/src/rules/prefer-default-export.js @@ -42,6 +42,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 + if (node.declaration.declarations) { node.declaration.declarations.forEach(function(declaration) { captureDeclaration(declaration.id) diff --git a/tests/src/rules/prefer-default-export.js b/tests/src/rules/prefer-default-export.js index 609288e49..5f61748f1 100644 --- a/tests/src/rules/prefer-default-export.js +++ b/tests/src/rules/prefer-default-export.js @@ -66,6 +66,11 @@ ruleTester.run('prefer-default-export', rule, { import * as foo from './foo';`, }), + test({ + code: `export type UserId = number;`, + parser: 'babel-eslint', + }), + // ...SYNTAX_CASES, ], invalid: [