Skip to content

Commit

Permalink
[Fix] default/TypeScript: avoid crash on export = with a MemberEx…
Browse files Browse the repository at this point in the history
…pression

Fixes #1841
  • Loading branch information
ljharb committed Jul 3, 2020
1 parent 878ce6e commit a5a277f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

## [Unreleased]

### Fixed
- [`default`]/TypeScript: avoid crash on `export =` with a MemberExpression ([#1841], thanks [@ljharb])

## [2.22.0] - 2020-06-26
### Added
- [`no-unused-modules`]: consider exported TypeScript interfaces, types and enums ([#1819], thanks [@nicolashenry])
Expand Down Expand Up @@ -722,6 +725,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#1841]: https://github.com/benmosher/eslint-plugin-import/issues/1841
[#1836]: https://github.com/benmosher/eslint-plugin-import/pull/1836
[#1835]: https://github.com/benmosher/eslint-plugin-import/pull/1835
[#1834]: https://github.com/benmosher/eslint-plugin-import/issues/1834
Expand Down
2 changes: 1 addition & 1 deletion src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ ExportMap.parse = function (path, content, context) {
if (includes(exports, n.type)) {
const exportedName = n.type === 'TSNamespaceExportDeclaration'
? n.id.name
: n.expression && n.expression.name || n.expression.id.name
: (n.expression && n.expression.name || (n.expression.id && n.expression.id.name) || null)
const declTypes = [
'VariableDeclaration',
'ClassDeclaration',
Expand Down
8 changes: 8 additions & 0 deletions tests/src/rules/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ context('TypeScript', function () {
tsconfigRootDir: path.resolve(__dirname, '../../files/typescript-export-as-default-namespace/'),
},
}),
test({
code: `import foobar from "./typescript-export-assign-property"`,
parser: parser,
settings: {
'import/parsers': { [parser]: ['.ts'] },
'import/resolver': { 'eslint-import-resolver-typescript': true },
},
}),
],

invalid: [
Expand Down

0 comments on commit a5a277f

Please sign in to comment.