@@ -95,9 +95,9 @@ export const resolve = (
95
95
96
96
// eslint-disable-next-line sonarjs/label-position, sonarjs/no-labels
97
97
createResolver: if ( ! resolver ) {
98
- // must be a array with 2+ items here already ensured by `normalizeOptions`
99
- const project = options . project as string [ ]
100
- for ( const tsconfigPath of project ) {
98
+ // must be an array with 2+ items here already ensured by `normalizeOptions`
99
+ const projects = sortProjectsByAffinity ( options . project as string [ ] , file )
100
+ for ( const tsconfigPath of projects ) {
101
101
const resolverCached = resolverCache . get ( tsconfigPath )
102
102
if ( resolverCached ) {
103
103
resolver = resolverCached
@@ -135,24 +135,23 @@ export const resolve = (
135
135
} ,
136
136
}
137
137
resolver = new ResolverFactory ( options )
138
- resolverCache . set ( tsconfigPath , resolver )
139
- break createResolver
138
+ const resolved = resolve ( source , file , options , resolver )
139
+ if ( resolved . found ) {
140
+ resolverCache . set ( tsconfigPath , resolver )
141
+ return resolved
142
+ }
140
143
}
141
144
142
145
log (
143
146
'no tsconfig matched' ,
144
147
file ,
145
148
'with' ,
146
- ...project ,
147
- ', trying from the the nearest one' ,
149
+ ...projects ,
150
+ ', trying from the the nearest one instead ' ,
148
151
)
149
- for ( const p of sortProjectsByAffinity ( project , file ) ) {
150
- const resolved = resolve (
151
- source ,
152
- file ,
153
- { ...options , project : p } ,
154
- resolver ,
155
- )
152
+
153
+ for ( const project of projects ) {
154
+ const resolved = resolve ( source , file , { ...options , project } , resolver )
156
155
if ( resolved . found ) {
157
156
return resolved
158
157
}
0 commit comments