Skip to content

Commit

Permalink
[Fix] order: avoid a crash on TypeScript’s export import syntax
Browse files Browse the repository at this point in the history
Fixes #1808.
  • Loading branch information
ljharb committed Jun 8, 2020
1 parent 1951ef5 commit cc604c1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/importType.js
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/rules/order.js
Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions tests/src/rules/order.js
Expand Up @@ -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({
Expand Down

0 comments on commit cc604c1

Please sign in to comment.