From 754038c6cc46f48f606da9a7c1f95a64536b63c4 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Thu, 17 Oct 2019 11:07:13 +0100 Subject: [PATCH] feat: follow symlinks in dependency graph --- lib/dependency-graph.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/dependency-graph.js b/lib/dependency-graph.js index 56b9b6bc..45997395 100644 --- a/lib/dependency-graph.js +++ b/lib/dependency-graph.js @@ -41,10 +41,15 @@ function gatherImported() { for (const {imports} of dependencyGraph.values()) { for (const [importedFilename, importedIdentifiers] of imports) { - filenames.add(importedFilename) + // require.resolve will expand any symlinks to their fully qualified + // directories. We can use this (with the absolute path given in + // importedFilename to quickly expand symlinks, which allows us to have + // symlinks (aka workspaces) in node_modules, and not fail the lint. + const fullyQualifiedImportedFilename = require.resolve(importedFilename) + filenames.add(fullyQualifiedImportedFilename) for (const importedIdentifier of importedIdentifiers) { - identifiers.add(`${importedFilename}#${importedIdentifier}`) + identifiers.add(`${fullyQualifiedImportedFilename}#${importedIdentifier}`) } } }