fix(linter): fix crashing with unwrap in import/no-cycle (#3035)

closes #3034
This commit is contained in:
Boshen 2024-04-20 16:59:13 +08:00 committed by GitHub
parent fe37da63ae
commit 598bbbaddc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -113,8 +113,11 @@ impl Rule for NoCycle {
let help = stack
.iter()
.map(|(specifier, path)| {
let path =
path.strip_prefix(&cwd).unwrap().to_string_lossy().replace('\\', "/");
let path = path
.strip_prefix(&cwd)
.unwrap_or(path)
.to_string_lossy()
.replace('\\', "/");
format!("-> {specifier} - {path}")
})
.collect::<Vec<_>>()