From d3b71f1e04f4e0e714f0ce0fe9ec39d7e566e2b6 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 9 May 2023 12:35:32 -0400 Subject: [PATCH] Run autofix on initial watcher pass (#4311) --- crates/ruff_cli/src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/ruff_cli/src/lib.rs b/crates/ruff_cli/src/lib.rs index c83132c27c..cb1f6cfe5c 100644 --- a/crates/ruff_cli/src/lib.rs +++ b/crates/ruff_cli/src/lib.rs @@ -217,6 +217,16 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result { warn_user_once!("--format 'text' is used in watch mode."); } + // Configure the file watcher. + let (tx, rx) = channel(); + let mut watcher = recommended_watcher(tx)?; + for file in &cli.files { + watcher.watch(file, RecursiveMode::Recursive)?; + } + if let Some(file) = pyproject_config.path.as_ref() { + watcher.watch(file, RecursiveMode::Recursive)?; + } + // Perform an initial run instantly. Printer::clear_screen()?; printer.write_to_user("Starting linter in watch mode...\n"); @@ -227,20 +237,10 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result { &overrides, cache.into(), noqa.into(), - flags::FixMode::None, + autofix, )?; printer.write_continuously(&messages)?; - // Configure the file watcher. - let (tx, rx) = channel(); - let mut watcher = recommended_watcher(tx)?; - for file in &cli.files { - watcher.watch(file, RecursiveMode::Recursive)?; - } - if let Some(file) = pyproject_config.path.as_ref() { - watcher.watch(file, RecursiveMode::Recursive)?; - } - // In watch mode, we may need to re-resolve the configuration. // TODO(charlie): Re-compute other derivative values, like the `printer`. let mut pyproject_config = pyproject_config;