diff --git a/CHANGELOG.md b/CHANGELOG.md index 0519555f0e52..69b327aab695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -149,6 +149,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b ``` Contributed by @ematipico +- Fix [#1774](https://github.com/biomejs/biome/issues/1774) by taking into account the option `--no-errors-on-unmatched` when running the CLI using `--changed`. Contributed by @antogyn #### Enhancements diff --git a/crates/biome_cli/src/changed.rs b/crates/biome_cli/src/changed.rs index 619e773183b3..5fc30006c541 100644 --- a/crates/biome_cli/src/changed.rs +++ b/crates/biome_cli/src/changed.rs @@ -24,9 +24,5 @@ pub(crate) fn get_changed_files( let filtered_changed_files = changed_files.iter().map(OsString::from).collect::>(); - if filtered_changed_files.is_empty() { - return Err(CliDiagnostic::no_files_processed()); - } - Ok(filtered_changed_files) } diff --git a/crates/biome_cli/src/execute/traverse.rs b/crates/biome_cli/src/execute/traverse.rs index d7ee4492a40b..641fb3dbdba8 100644 --- a/crates/biome_cli/src/execute/traverse.rs +++ b/crates/biome_cli/src/execute/traverse.rs @@ -143,7 +143,10 @@ pub(crate) fn traverse( inputs: Vec, ) -> Result<(), CliDiagnostic> { init_thread_pool(); - if inputs.is_empty() && execution.as_stdin_file().is_none() { + if inputs.is_empty() + && execution.as_stdin_file().is_none() + && !cli_options.no_errors_on_unmatched + { return Err(CliDiagnostic::missing_argument( "", format!("{}", execution.traversal_mode), diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs index bb8beda0d12e..a2d4dd752a4f 100644 --- a/crates/biome_cli/tests/commands/lint.rs +++ b/crates/biome_cli/tests/commands/lint.rs @@ -2683,6 +2683,44 @@ fn should_not_process_ignored_file_even_if_its_changed() { )); } +#[test] +fn should_not_error_for_no_changed_files_with_no_errors_on_unmatched() { + let mut console = BufferConsole::default(); + let mut fs = MemoryFileSystem::default(); + + let file_path = Path::new("file.js"); + fs.insert(file_path.into(), r#"console.log('file');"#.as_bytes()); + + let file_path2 = Path::new("file2.js"); + fs.insert(file_path2.into(), r#"console.log('file2');"#.as_bytes()); + + let result = run_cli( + DynRef::Borrowed(&mut fs), + &mut console, + Args::from( + [ + ("lint"), + "--changed", + "--since=main", + "--no-errors-on-unmatched", + file_path.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), + ); + + assert!(result.is_ok(), "run_cli returned {result:?}"); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "should_not_error_for_no_changed_files_with_no_errors_on_unmatched", + fs, + console, + result, + )); +} + #[test] fn lint_syntax_rules() { let mut fs = MemoryFileSystem::default(); diff --git a/crates/biome_cli/tests/snapshots/main_commands_lint/should_not_error_for_no_changed_files_with_no_errors_on_unmatched.snap b/crates/biome_cli/tests/snapshots/main_commands_lint/should_not_error_for_no_changed_files_with_no_errors_on_unmatched.snap new file mode 100644 index 000000000000..5809a819c7a6 --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_commands_lint/should_not_error_for_no_changed_files_with_no_errors_on_unmatched.snap @@ -0,0 +1,23 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: content +--- +## `file.js` + +```js +console.log('file'); +``` + +## `file2.js` + +```js +console.log('file2'); +``` + +# Emitted Messages + +```block +Checked 0 file(s) in