Skip to content

Commit b22a183

Browse files
AndrewLeedhamljharb
andcommitted
[Fix] default: avoid crash with export =
Fixes #1818. Co-authored-by: AndrewLeedham <[email protected]> Co-authored-by: Jordan Harband <[email protected]>
1 parent 6f5d95a commit b22a183

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1010

1111
### Fixed
1212
- [`no-extraneous-dependencies`]/TypeScript: do not error when importing type from dev dependencies ([#1820], thanks [@fernandopasik])
13+
- [`default`]: avoid crash with `export =` ([#1822], thanks [@AndrewLeedham])
1314

1415
### Changed
1516
- [`no-extraneous-dependencies`]: add tests for importing types ([#1824], thanks [@taye])
@@ -711,6 +712,7 @@ for info on changes for earlier releases.
711712
[`memo-parser`]: ./memo-parser/README.md
712713

713714
[#1824]: https://github.com/benmosher/eslint-plugin-import/pull/1824
715+
[#1822]: https://github.com/benmosher/eslint-plugin-import/pull/1822
714716
[#1820]: https://github.com/benmosher/eslint-plugin-import/pull/1820
715717
[#1819]: https://github.com/benmosher/eslint-plugin-import/pull/1819
716718
[#1802]: https://github.com/benmosher/eslint-plugin-import/pull/1802
@@ -1230,3 +1232,4 @@ for info on changes for earlier releases.
12301232
[@nicolashenry]: https://github.com/nicolashenry
12311233
[@fernandopasik]: https://github.com/fernandopasik
12321234
[@taye]: https://github.com/taye
1235+
[@AndrewLeedham]: https://github.com/AndrewLeedham

src/ExportMap.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ ExportMap.parse = function (path, content, context) {
562562

563563
// This doesn't declare anything, but changes what's being exported.
564564
if (includes(exports, n.type)) {
565-
const exportedName = n.expression && n.expression.name || n.id.name
565+
const exportedName = n.type === 'TSNamespaceExportDeclaration'
566+
? n.id.name
567+
: n.expression && n.expression.name || n.expression.id.name
566568
const declTypes = [
567569
'VariableDeclaration',
568570
'ClassDeclaration',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export = function foo() {};

tests/src/rules/default.js

+8
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ context('TypeScript', function () {
174174
'import/resolver': { 'eslint-import-resolver-typescript': true },
175175
},
176176
}),
177+
test({
178+
code: `import foobar from "./typescript-export-assign-function"`,
179+
parser: parser,
180+
settings: {
181+
'import/parsers': { [parser]: ['.ts'] },
182+
'import/resolver': { 'eslint-import-resolver-typescript': true },
183+
},
184+
}),
177185
test({
178186
code: `import foobar from "./typescript-export-assign-mixed"`,
179187
parser: parser,

0 commit comments

Comments
 (0)