diff --git a/CHANGELOG.md b/CHANGELOG.md index ca63eb5f8..cb89f8723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ## [Unreleased] +### Fixed +- [`order`]: avoid a crash on TypeScript’s `export import` syntax ([#1808], thanks [@ljharb]) + ## [2.21.1] - 2020-06-07 ### Fixed - TypeScript: [`import/named`]: avoid requiring `typescript` when not using TS ([#1805], thanks [@ljharb]) @@ -897,6 +900,8 @@ for info on changes for earlier releases. [#211]: https://github.com/benmosher/eslint-plugin-import/pull/211 [#164]: https://github.com/benmosher/eslint-plugin-import/pull/164 [#157]: https://github.com/benmosher/eslint-plugin-import/pull/157 +[#1808]: https://github.com/benmosher/eslint-plugin-import/issues/1808 +[#1805]: https://github.com/benmosher/eslint-plugin-import/issues/1805 [#1565]: https://github.com/benmosher/eslint-plugin-import/issues/1565 [#1366]: https://github.com/benmosher/eslint-plugin-import/issues/1366 [#1334]: https://github.com/benmosher/eslint-plugin-import/issues/1334 diff --git a/src/core/importType.js b/src/core/importType.js index 4d56b86d4..ff2d10b60 100644 --- a/src/core/importType.js +++ b/src/core/importType.js @@ -12,7 +12,7 @@ function baseModule(name) { } export function isAbsolute(name) { - return name.indexOf('/') === 0 + return name && name.startsWith('/') } // path is defined only when a resolver resolves to a non-standard path diff --git a/src/rules/order.js b/src/rules/order.js index 9edac3af9..b40714540 100644 --- a/src/rules/order.js +++ b/src/rules/order.js @@ -611,6 +611,8 @@ module.exports = { let name if (node.moduleReference.type === 'TSExternalModuleReference') { name = node.moduleReference.expression.value + } else if (node.isExport) { + name = node.moduleReference.name } else { name = null } diff --git a/tests/src/rules/order.js b/tests/src/rules/order.js index bad48bf38..e8ee82ec6 100644 --- a/tests/src/rules/order.js +++ b/tests/src/rules/order.js @@ -183,6 +183,13 @@ ruleTester.run('order', rule, { `, parser, }), + + test({ + code: ` + export import CreateSomething = _CreateSomething; + `, + parser, + }), ]), // Adding unknown import types (e.g. using a resolver alias via babel) to the groups. test({