Skip to content

Commit 754038c

Browse files
committed
feat: follow symlinks in dependency graph
1 parent 40f8d9a commit 754038c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/dependency-graph.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ function gatherImported() {
4141

4242
for (const {imports} of dependencyGraph.values()) {
4343
for (const [importedFilename, importedIdentifiers] of imports) {
44-
filenames.add(importedFilename)
44+
// require.resolve will expand any symlinks to their fully qualified
45+
// directories. We can use this (with the absolute path given in
46+
// importedFilename to quickly expand symlinks, which allows us to have
47+
// symlinks (aka workspaces) in node_modules, and not fail the lint.
48+
const fullyQualifiedImportedFilename = require.resolve(importedFilename)
49+
filenames.add(fullyQualifiedImportedFilename)
4550

4651
for (const importedIdentifier of importedIdentifiers) {
47-
identifiers.add(`${importedFilename}#${importedIdentifier}`)
52+
identifiers.add(`${fullyQualifiedImportedFilename}#${importedIdentifier}`)
4853
}
4954
}
5055
}

0 commit comments

Comments
 (0)