From 4665ec5a687d068e4e4ab19e3dbde7d0c65bbee4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 1 Feb 2020 14:12:02 -0800 Subject: [PATCH] [Fix] `no-absolute-path`: fix a crash with invalid import syntax Fixes #1616 --- CHANGELOG.md | 2 ++ src/rules/no-absolute-path.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 609762ffb..bd7f900ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ## [Unreleased] ### Fixed +- [`no-absolute-path`]: fix a crash with invalid import syntax ([#1616], thanks [@ljharb]) - [`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]) - [`extentions`]: Fix scope regex ([#1611], thanks [@yordis]) @@ -649,6 +650,7 @@ for info on changes for earlier releases. [#1635]: https://github.com/benmosher/eslint-plugin-import/issues/1635 [#1620]: https://github.com/benmosher/eslint-plugin-import/pull/1620 +[#1616]: https://github.com/benmosher/eslint-plugin-import/issues/1616 [#1613]: https://github.com/benmosher/eslint-plugin-import/issues/1613 [#1612]: https://github.com/benmosher/eslint-plugin-import/pull/1612 [#1611]: https://github.com/benmosher/eslint-plugin-import/pull/1611 diff --git a/src/rules/no-absolute-path.js b/src/rules/no-absolute-path.js index 4b7a8fcc2..2cc0f6ae0 100644 --- a/src/rules/no-absolute-path.js +++ b/src/rules/no-absolute-path.js @@ -13,7 +13,7 @@ module.exports = { create: function (context) { function reportIfAbsolute(source) { - if (isAbsolute(source.value)) { + if (typeof source.value === 'string' && isAbsolute(source.value)) { context.report(source, 'Do not import modules using an absolute path') } }