Skip to content

Commit 9b9249d

Browse files
committed
refactor(oxc_language_server): remove unnecessary globset (#12861)
Related to #12825
1 parent bc1d716 commit 9b9249d

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_language_server/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ oxc_linter = { workspace = true, features = ["language_server"] }
2929
#
3030
env_logger = { workspace = true, features = ["humantime"] }
3131
futures = { workspace = true }
32-
globset = { workspace = true }
3332
ignore = { workspace = true, features = ["simd-accel"] }
3433
log = { workspace = true }
3534
papaya = { workspace = true }

crates/oxc_language_server/src/linter/server_linter.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::path::{Component, Path, PathBuf};
22
use std::sync::Arc;
33

4-
use globset::Glob;
54
use ignore::gitignore::Gitignore;
65
use log::{debug, warn};
76
use rustc_hash::{FxBuildHasher, FxHashMap};
@@ -164,14 +163,8 @@ impl ServerLinter {
164163
(nested_configs, extended_paths)
165164
}
166165

166+
#[expect(clippy::filetype_is_file)]
167167
fn create_ignore_glob(root_path: &Path, oxlintrc: &Oxlintrc) -> Vec<Gitignore> {
168-
let mut builder = globset::GlobSetBuilder::new();
169-
// Collecting all ignore files
170-
builder.add(Glob::new("**/.eslintignore").unwrap());
171-
builder.add(Glob::new("**/.gitignore").unwrap());
172-
173-
let ignore_file_glob_set = builder.build().unwrap();
174-
175168
let walk = ignore::WalkBuilder::new(root_path)
176169
.ignore(true)
177170
.hidden(false)
@@ -181,11 +174,17 @@ impl ServerLinter {
181174

182175
let mut gitignore_globs = vec![];
183176
for entry in walk {
177+
if !entry.file_type().is_some_and(|v| v.is_file()) {
178+
continue;
179+
}
184180
let ignore_file_path = entry.path();
185-
if !ignore_file_glob_set.is_match(ignore_file_path) {
181+
if !ignore_file_path
182+
.file_name()
183+
.and_then(std::ffi::OsStr::to_str)
184+
.is_some_and(|v| [".eslintignore", ".gitignore"].contains(&v))
185+
{
186186
continue;
187187
}
188-
189188
if let Some(ignore_file_dir) = ignore_file_path.parent() {
190189
let mut builder = ignore::gitignore::GitignoreBuilder::new(ignore_file_dir);
191190
builder.add(ignore_file_path);

0 commit comments

Comments
 (0)