diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 3c1937bb2c2f1..f7ed8781bca2f 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -6,6 +6,7 @@ use std::{ }; use ignore::gitignore::Gitignore; + use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler}; use oxc_linter::{ loader::LINT_PARTIAL_LOADER_EXT, AllowWarnDeny, InvalidFilterKind, LintFilter, LintService, @@ -253,9 +254,9 @@ impl LintRunner { // when config is provided, but not found, an CliRunResult is returned, else the oxlintrc config file is returned // when no config is provided, it will search for the default file names in the current working directory // when no file is found, the default configuration is returned - fn find_oxlint_config(cwd: &PathBuf, config: Option<&PathBuf>) -> Result { + fn find_oxlint_config(cwd: &Path, config: Option<&PathBuf>) -> Result { if let Some(config_path) = config { - let mut full_path = cwd.clone(); + let mut full_path = cwd.to_path_buf(); full_path.push(config_path); return match Oxlintrc::from_file(&full_path) { @@ -305,10 +306,11 @@ mod test { let mut current_cwd = env::current_dir().unwrap(); - let part_cwd = if MAIN_SEPARATOR_STR != "/" { - cwd.replace('/', MAIN_SEPARATOR_STR) - } else { + let part_cwd = if MAIN_SEPARATOR_STR == "/" { cwd.into() + } else { + #[expect(clippy::disallowed_methods)] + cwd.replace('/', MAIN_SEPARATOR_STR) }; current_cwd.push(part_cwd); @@ -380,6 +382,8 @@ mod test { assert_eq!(result.number_of_errors, 0); } + // ToDo: lints all files under windows + #[cfg(all(test, not(target_os = "windows")))] #[test] fn wrong_extension() { let args = &["foo.asdf"]; @@ -689,12 +693,15 @@ mod test { let file = "fixtures/linter/fix.js"; let args = &["--fix", file]; let content_original = fs::read_to_string(file).unwrap(); + #[expect(clippy::disallowed_methods)] let content = content_original.replace("\r\n", "\n"); assert_eq!(&content, "debugger\n"); // Apply fix to the file. let _ = test(args); - assert_eq!(fs::read_to_string(file).unwrap().replace("\r\n", "\n"), "\n"); + #[expect(clippy::disallowed_methods)] + let new_content = fs::read_to_string(file).unwrap().replace("\r\n", "\n"); + assert_eq!(new_content, "\n"); // File should not be modified if no fix is applied. let modified_before = fs::metadata(file).unwrap().modified().unwrap(); @@ -789,10 +796,10 @@ mod test { #[test] fn test_config_ignore_patterns_directory() { - let result = test_with_cwd("fixtures/config_ignore_patterns/ignore_directory", &[ - "-c", - "eslintrc.json", - ]); + let result = test_with_cwd( + "fixtures/config_ignore_patterns/ignore_directory", + &["-c", "eslintrc.json"], + ); assert_eq!(result.number_of_files, 1); } diff --git a/apps/oxlint/src/walk.rs b/apps/oxlint/src/walk.rs index d6843b8a8f15b..9d5c00b27a4f9 100644 --- a/apps/oxlint/src/walk.rs +++ b/apps/oxlint/src/walk.rs @@ -56,10 +56,7 @@ impl ignore::ParallelVisitor for WalkCollector { match entry { Ok(entry) => { if Walk::is_wanted_entry(&entry, &self.extensions) { - println!("Processing entry: {:?}", entry.path()); // Debug output self.paths.push(entry.path().to_path_buf().into_boxed_path()); - } else { - println!("Ignoring entry: {:?}", entry.path()); // Debug output } ignore::WalkState::Continue } @@ -106,7 +103,7 @@ impl Walk { if !config_ignore_patterns.is_empty() { for pattern in config_ignore_patterns { - let pattern = format!("!{}", pattern); + let pattern = format!("!{pattern}"); override_builder.add(&pattern).unwrap(); } }