@@ -6,6 +6,7 @@ use biome_console::markup;
6
6
use biome_diagnostics:: Severity ;
7
7
use biome_js_syntax:: AnyJsImportLike ;
8
8
use biome_module_graph:: { JsImportPath , JsImportPhase , JsModuleInfo } ;
9
+ use biome_resolver:: ResolvedPath ;
9
10
use biome_rowan:: AstNode ;
10
11
use biome_rule_options:: no_import_cycles:: NoImportCyclesOptions ;
11
12
use camino:: { Utf8Path , Utf8PathBuf } ;
@@ -154,7 +155,7 @@ declare_lint_rule! {
154
155
155
156
impl Rule for NoImportCycles {
156
157
type Query = ResolvedImports < AnyJsImportLike > ;
157
- type State = Box < [ Box < str > ] > ;
158
+ type State = Vec < String > ;
158
159
type Signals = Option < Self :: State > ;
159
160
type Options = NoImportCyclesOptions ;
160
161
@@ -227,10 +228,10 @@ fn find_cycle(
227
228
ctx : & RuleContext < NoImportCycles > ,
228
229
start_path : & Utf8Path ,
229
230
mut module_info : JsModuleInfo ,
230
- ) -> Option < Box < [ Box < str > ] > > {
231
+ ) -> Option < Vec < String > > {
231
232
let options = ctx. options ( ) ;
232
233
let mut seen = FxHashSet :: default ( ) ;
233
- let mut stack: Vec < ( Box < str > , JsModuleInfo ) > = Vec :: new ( ) ;
234
+ let mut stack: Vec < ( ResolvedPath , JsModuleInfo ) > = Vec :: new ( ) ;
234
235
235
236
' outer: loop {
236
237
for JsImportPath {
@@ -252,17 +253,21 @@ fn find_cycle(
252
253
253
254
if path == ctx. file_path ( ) {
254
255
// Return all the paths from `start_path` to `resolved_path`:
255
- let paths = Some ( start_path. as_str ( ) )
256
+ let paths = Some ( start_path. to_string ( ) )
256
257
. into_iter ( )
257
- . map ( Box :: from)
258
- . chain ( stack. into_iter ( ) . map ( |( path, _) | path) )
259
- . chain ( Some ( Box :: from ( path. as_str ( ) ) ) )
258
+ . chain (
259
+ stack
260
+ . iter ( )
261
+ . filter_map ( |( path, _) | path. as_path ( ) )
262
+ . map ( ToString :: to_string) ,
263
+ )
264
+ . chain ( Some ( path. to_string ( ) ) )
260
265
. collect ( ) ;
261
266
return Some ( paths) ;
262
267
}
263
268
264
269
if let Some ( next_module_info) = ctx. module_info_for_path ( path) {
265
- stack. push ( ( path . as_str ( ) . into ( ) , module_info) ) ;
270
+ stack. push ( ( resolved_path . clone ( ) , module_info) ) ;
266
271
module_info = next_module_info;
267
272
continue ' outer;
268
273
}
0 commit comments