Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/oxc_language_server/src/linter/server_linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use ignore::gitignore::Gitignore;
use log::{debug, warn};
use oxc_linter::{AllowWarnDeny, LintIgnoreMatcher};
use rustc_hash::{FxBuildHasher, FxHashMap};
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
use tokio::sync::Mutex;
use tower_lsp_server::lsp_types::Uri;

Expand Down Expand Up @@ -40,7 +40,7 @@ pub struct ServerLinter {
gitignore_glob: Vec<Gitignore>,
lint_on_run: Run,
diagnostics: ServerLinterDiagnostics,
pub extended_paths: Vec<PathBuf>,
pub extended_paths: FxHashSet<PathBuf>,
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -189,8 +189,8 @@ impl ServerLinter {
root_path: &Path,
options: &LSPLintOptions,
nested_ignore_patterns: &mut Vec<(Vec<String>, PathBuf)>,
) -> (ConcurrentHashMap<PathBuf, Config>, Vec<PathBuf>) {
let mut extended_paths = Vec::new();
) -> (ConcurrentHashMap<PathBuf, Config>, FxHashSet<PathBuf>) {
let mut extended_paths = FxHashSet::default();
// nested config is disabled, no need to search for configs
if !options.use_nested_configs() {
return (ConcurrentHashMap::default(), extended_paths);
Expand Down
17 changes: 3 additions & 14 deletions crates/oxc_language_server/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,8 @@ mod test_init_watchers {
let tester = Tester::new("fixtures/watcher/linter_extends", &Options::default());
let watchers = tester.init_watchers();

// The root `.oxlintrc.json` extends `./lint.json -> 2 watchers
// The nested configs are enabled, so it finds `.oxlintrc.json` a second time -> 3 watchers
assert_eq!(watchers.len(), 3);
// The `.oxlintrc.json` extends `./lint.json -> 2 watchers
assert_eq!(watchers.len(), 2);

// nested configs pattern
assert_eq!(
Expand All @@ -529,24 +528,14 @@ mod test_init_watchers {
})
);

// nested config extends
// extends of root config
assert_eq!(
watchers[1].glob_pattern,
GlobPattern::Relative(RelativePattern {
base_uri: OneOf::Right(tester.worker.get_root_uri().clone()),
pattern: "lint.json".to_string(),
})
);

// base config extends
// TODO: filter duplicates
assert_eq!(
watchers[2].glob_pattern,
GlobPattern::Relative(RelativePattern {
base_uri: OneOf::Right(tester.worker.get_root_uri().clone()),
pattern: "lint.json".to_string(),
})
);
}

#[test]
Expand Down
Loading