diff --git a/apps/oxfmt/src/walk.rs b/apps/oxfmt/src/walk.rs index 2479adcae79d4..5931d6c8f68e6 100644 --- a/apps/oxfmt/src/walk.rs +++ b/apps/oxfmt/src/walk.rs @@ -32,11 +32,16 @@ impl ignore::ParallelVisitor for WalkVisitor { fn visit(&mut self, entry: Result) -> ignore::WalkState { match entry { Ok(entry) => { - // Skip if we can't get file type or if it's a directory - if let Some(file_type) = entry.file_type() - && !file_type.is_dir() - && let Some(source_type) = get_supported_source_type(entry.path()) - { + let Some(file_type) = entry.file_type() else { + return ignore::WalkState::Continue; + }; + if file_type.is_dir() { + // Skip traversing `.git` directories because `.git` is not a special case for `.hidden(false)`. + // + if entry.file_name() == ".git" { + return ignore::WalkState::Skip; + } + } else if let Some(source_type) = get_supported_source_type(entry.path()) { let walk_entry = WalkEntry { path: entry.path().as_os_str().into(), source_type }; // Send each entry immediately through the channel diff --git a/apps/oxlint/src/walk.rs b/apps/oxlint/src/walk.rs index e5b749b481c29..322b95435365e 100644 --- a/apps/oxlint/src/walk.rs +++ b/apps/oxlint/src/walk.rs @@ -52,6 +52,11 @@ impl ignore::ParallelVisitor for WalkCollector { fn visit(&mut self, entry: Result) -> ignore::WalkState { match entry { Ok(entry) => { + // Skip traversing `.git` directories because `.git` is not a special case for `.hidden(false)`. + // + if entry.file_type().is_some_and(|ty| ty.is_dir()) && entry.file_name() == ".git" { + return ignore::WalkState::Skip; + } if Walk::is_wanted_entry(&entry, &self.extensions) { self.paths.push(entry.path().as_os_str().into()); }