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
  • Loading branch information
ljharb committed Jun 8, 2020
1 parent 0179440 commit 13017ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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 13017ed

Please sign in to comment.