Support relative imports in banned-api enforcement (#4025)

This commit is contained in:
Charlie Marsh 2023-04-19 14:30:13 -04:00 committed by GitHub
parent f13a161ead
commit 7fa1da20fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 157 additions and 19 deletions

View file

@ -174,8 +174,12 @@ impl<'a> Context<'a> {
if name.starts_with('.') {
if let Some(module) = &self.module_path {
let mut source_path = from_relative_import(module, name);
source_path.extend(call_path.into_iter().skip(1));
Some(source_path)
if source_path.is_empty() {
None
} else {
source_path.extend(call_path.into_iter().skip(1));
Some(source_path)
}
} else {
None
}
@ -191,8 +195,12 @@ impl<'a> Context<'a> {
if name.starts_with('.') {
if let Some(module) = &self.module_path {
let mut source_path = from_relative_import(module, name);
source_path.extend(call_path.into_iter().skip(1));
Some(source_path)
if source_path.is_empty() {
None
} else {
source_path.extend(call_path.into_iter().skip(1));
Some(source_path)
}
} else {
None
}