Skip to content

Commit 4079482

Browse files
committed
[Fix] extensions: avoid crashing on partially typed import/export statements
Fixes #2118.
1 parent 7aea664 commit 4079482

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: CHANGELOG.md

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

99
### Fixed
1010
- [`no-duplicates`]: ensure autofix avoids excessive newlines ([#2028], thanks [@ertrzyiks])
11+
- [`extensions`]: avoid crashing on partially typed import/export statements ([#2118], thanks [@ljharb])
1112

1213
## [2.23.4] - 2021-05-29
1314

@@ -1043,6 +1044,7 @@ for info on changes for earlier releases.
10431044
[#211]: https://github.com/benmosher/eslint-plugin-import/pull/211
10441045
[#164]: https://github.com/benmosher/eslint-plugin-import/pull/164
10451046
[#157]: https://github.com/benmosher/eslint-plugin-import/pull/157
1047+
[#2118]: https://github.com/benmosher/eslint-plugin-import/issues/2118
10461048
[#2067]: https://github.com/benmosher/eslint-plugin-import/issues/2067
10471049
[#2056]: https://github.com/benmosher/eslint-plugin-import/issues/2056
10481050
[#2063]: https://github.com/benmosher/eslint-plugin-import/issues/2063

Diff for: src/rules/extensions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ module.exports = {
136136
}
137137

138138
function checkFileExtension(source) {
139-
// bail if the declaration doesn't have a source, e.g. "export { foo };"
140-
if (!source) return;
139+
// bail if the declaration doesn't have a source, e.g. "export { foo };", or if it's only partially typed like in an editor
140+
if (!source || !source.value) return;
141141

142142
const importPathWithQueryString = source.value;
143143

0 commit comments

Comments
 (0)