Skip to content

Commit

Permalink
fix: return if no matchedPackage (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdanil committed Oct 28, 2020
1 parent 51cac51 commit 07f6bdc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/rules/no-internal-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const create = context => {
return moduleVisitor(node => {
const { name, path: internalPath } = tryParse(node.value);
const matchedPackage = packages.find(pkg => pkg.package.name === name);

if (!internalPath) return;
if (!matchedPackage) return;

const packageRoot = matchedPackage.location;

// Need to take care of "files" field, since they are
Expand All @@ -52,8 +56,6 @@ export const create = context => {
});
const absoluteInternalPath = path.join(packageRoot, internalPath);

if (!internalPath) return;
if (!matchedPackage) return;
if (absolutePathsForFiles) {
const isImportWithinFiles = absolutePathsForFiles.some(maybeGlob => {
// If import doesn't have an extension, strip it from the file entry
Expand Down

0 comments on commit 07f6bdc

Please sign in to comment.