File tree 2 files changed +18
-1
lines changed
packages/cli/src/services/check-parser
__tests__/check-parser-fixtures/builtin-with-node-prefix
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { } from 'node:path'
2
2
import { } from 'node:url'
3
+ import { } from 'node:fs/promises'
3
4
import { } from 'crypto'
5
+ import { } from 'timers/promises'
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ export class Parser {
100
100
this . checkUnsupportedModules = options . checkUnsupportedModules ?? true
101
101
}
102
102
103
- supportsModule ( importPath : string ) {
103
+ supportsModule ( importPath : string ) : boolean {
104
104
if ( this . supportedModules . has ( importPath ) ) {
105
105
return true
106
106
}
@@ -109,6 +109,21 @@ export class Parser {
109
109
return true
110
110
}
111
111
112
+ // Check namespaced modules and module subpaths.
113
+ if ( importPath . indexOf ( '/' ) !== - 1 ) {
114
+ if ( importPath . startsWith ( '@' ) ) {
115
+ const [ namespace , moduleName ] = importPath . split ( '/' , 3 )
116
+ if ( this . supportedModules . has ( namespace + '/' + moduleName ) ) {
117
+ return true
118
+ }
119
+ } else {
120
+ // Recurse to cover values with and without node: prefix.
121
+ // This will not endlessly recurse because we remove the slash.
122
+ const [ moduleName ] = importPath . split ( '/' , 2 )
123
+ return this . supportsModule ( moduleName )
124
+ }
125
+ }
126
+
112
127
return false
113
128
}
114
129
You can’t perform that action at this time.
0 commit comments