Skip to content

Commit

Permalink
[Fix] extensions: for invalid code where name does not exist, do …
Browse files Browse the repository at this point in the history
…not crash

Fixes #1613
  • Loading branch information
ljharb committed Jan 15, 2020
1 parent b4d5fd3 commit 3908e6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
## [Unreleased]
### Fixed
- [`import/external-module-folders` setting] now correctly works with directories containing modules symlinked from `node_modules` ([#1605], thanks [@skozin])
- [`extensions`]: for invalid code where `name` does not exist, do not crash ([#1613], thanks [@ljharb])

### Changed
- [`import/external-module-folders` setting] behavior is more strict now: it will only match complete path segments ([#1605], thanks [@skozin])
Expand Down Expand Up @@ -641,6 +642,7 @@ for info on changes for earlier releases.

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

[#1613]: https://github.com/benmosher/eslint-plugin-import/issues/1613
[#1605]: https://github.com/benmosher/eslint-plugin-import/pull/1605
[#1589]: https://github.com/benmosher/eslint-plugin-import/issues/1589
[#1586]: https://github.com/benmosher/eslint-plugin-import/pull/1586
Expand Down
6 changes: 3 additions & 3 deletions src/core/importType.js
Expand Up @@ -17,7 +17,7 @@ export function isAbsolute(name) {

// path is defined only when a resolver resolves to a non-standard path
export function isBuiltIn(name, settings, path) {
if (path) return false
if (path || !name) return false
const base = baseModule(name)
const extras = (settings && settings['import/core-modules']) || []
return coreModules[base] || extras.indexOf(base) > -1
Expand Down Expand Up @@ -52,12 +52,12 @@ export function isExternalModuleMain(name, settings, path) {

const scopedRegExp = /^@[^/]+\/?[^/]+/
export function isScoped(name) {
return scopedRegExp.test(name)
return name && scopedRegExp.test(name)
}

const scopedMainRegExp = /^@[^/]+\/?[^/]+$/
export function isScopedMain(name) {
return scopedMainRegExp.test(name)
return name && scopedMainRegExp.test(name)
}

function isInternalModule(name, settings, path) {
Expand Down

0 comments on commit 3908e6d

Please sign in to comment.