Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {} from 'node:path'
import {} from 'node:url'
import {} from 'node:fs/promises'
import {} from 'crypto'
import {} from 'timers/promises'
17 changes: 16 additions & 1 deletion packages/cli/src/services/check-parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class Parser {
this.checkUnsupportedModules = options.checkUnsupportedModules ?? true
}

supportsModule (importPath: string) {
supportsModule (importPath: string): boolean {
if (this.supportedModules.has(importPath)) {
return true
}
Expand All @@ -109,6 +109,21 @@ export class Parser {
return true
}

// Check namespaced modules and module subpaths.
if (importPath.indexOf('/') !== -1) {
if (importPath.startsWith('@')) {
const [namespace, moduleName] = importPath.split('/', 3)
if (this.supportedModules.has(namespace + '/' + moduleName)) {
return true
}
} else {
// Recurse to cover values with and without node: prefix.
// This will not endlessly recurse because we remove the slash.
const [moduleName] = importPath.split('/', 2)
return this.supportsModule(moduleName)
}
}

return false
}

Expand Down
Loading