diff --git a/.changeset/fair-trains-protect.md b/.changeset/fair-trains-protect.md
new file mode 100644
index 000000000000..5d5d07f2f037
--- /dev/null
+++ b/.changeset/fair-trains-protect.md
@@ -0,0 +1,7 @@
+---
+"@biomejs/biome": minor
+---
+
+Biome VCS integration now supports nested ignore files.
+
+For `git`, if a `.gitignore` is found in a nested folder `root/packages/foo/`, and it contains the pattern `dist/`, only files and directories inside `root/packages/foo/dist` are matched.
diff --git a/biome.json b/biome.json
index 4c6e8a021235..5af76c8c9e04 100644
--- a/biome.json
+++ b/biome.json
@@ -25,14 +25,9 @@
"**/benchmark/**",
"!**/crates/**",
"!**/dist/**",
- "!**/.astro/**",
- "!**/assets/**",
"!**/packages/@biomejs/backend-jsonrpc/src/workspace.ts",
- "!**/public/**",
"!**/__snapshots__",
"!**/undefined/**",
- "!**/_fonts/**",
- "!**/packages/@biomejs/wasm-*",
"!**/benchmark/target/**"
]
},
diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs
index 614420e94eac..7cd7ef828072 100644
--- a/crates/biome_cli/src/commands/mod.rs
+++ b/crates/biome_cli/src/commands/mod.rs
@@ -26,9 +26,7 @@ use biome_console::{markup, Console, ConsoleExt};
use biome_diagnostics::{Diagnostic, PrintDiagnostic, Severity};
use biome_fs::{BiomePath, FileSystem};
use biome_grit_patterns::GritTargetLanguage;
-use biome_service::configuration::{
- load_configuration, load_editorconfig, ConfigurationExt, LoadedConfiguration,
-};
+use biome_service::configuration::{load_configuration, load_editorconfig, LoadedConfiguration};
use biome_service::documentation::Doc;
use biome_service::projects::ProjectKey;
use biome_service::workspace::{
@@ -788,9 +786,6 @@ pub(crate) trait CommandRunner: Sized {
);
let configuration_path = loaded_configuration.directory_path.clone();
let configuration = self.merge_configuration(loaded_configuration, fs, console)?;
- let vcs_base_path = configuration_path.clone().or(fs.working_directory());
- let (vcs_base_path, gitignore_matches) =
- configuration.retrieve_gitignore_matches(fs, vcs_base_path.as_deref())?;
let paths = self.get_files_to_process(fs, &configuration)?;
let project_path = fs
.working_directory()
@@ -805,8 +800,6 @@ pub(crate) trait CommandRunner: Sized {
project_key,
workspace_directory: configuration_path.map(BiomePath::from),
configuration,
- vcs_base_path: vcs_base_path.map(BiomePath::from),
- gitignore_matches,
})?;
for diagnostic in &result.diagnostics {
console.log(markup! {{PrintDiagnostic::simple(diagnostic)}});
@@ -820,7 +813,7 @@ pub(crate) trait CommandRunner: Sized {
path: Some(project_path),
})?;
for diagnostic in result.diagnostics {
- if diagnostic.severity() == Severity::Fatal {
+ if diagnostic.severity() >= Severity::Error {
console.log(markup! {{PrintDiagnostic::simple(&diagnostic)}});
}
}
diff --git a/crates/biome_cli/src/commands/rage.rs b/crates/biome_cli/src/commands/rage.rs
index 0e5d8847e8db..aea25f64630a 100644
--- a/crates/biome_cli/src/commands/rage.rs
+++ b/crates/biome_cli/src/commands/rage.rs
@@ -220,7 +220,7 @@ impl Display for RageConfiguration<'_> {
let vcs_enabled = configuration.is_vcs_enabled();
let mut settings = Settings::default();
settings
- .merge_with_configuration(configuration.clone(), None, None, &[])
+ .merge_with_configuration(configuration.clone(), None)
.unwrap();
let status = if !diagnostics.is_empty() {
diff --git a/crates/biome_cli/src/execute/process_file.rs b/crates/biome_cli/src/execute/process_file.rs
index 68123022def2..1dca9005fc2b 100644
--- a/crates/biome_cli/src/execute/process_file.rs
+++ b/crates/biome_cli/src/execute/process_file.rs
@@ -10,7 +10,9 @@ use crate::execute::traverse::TraversalOptions;
use crate::execute::TraversalMode;
use biome_diagnostics::{category, DiagnosticExt, DiagnosticTags, Error};
use biome_fs::BiomePath;
-use biome_service::workspace::{FeatureKind, SupportKind, SupportsFeatureParams};
+use biome_service::workspace::{
+ DocumentFileSource, FeatureKind, SupportKind, SupportsFeatureParams,
+};
use check::check_file;
use format::format;
use lint::lint;
@@ -143,7 +145,7 @@ pub(crate) fn process_file(ctx: &TraversalOptions, biome_path: &BiomePath) -> Fi
// first we stop if there are some files that don't have ALL features enabled, e.g. images, fonts, etc.
if file_features.is_ignored() || file_features.is_not_enabled() {
return Ok(FileStatus::Ignored);
- } else if file_features.is_not_supported() {
+ } else if file_features.is_not_supported() || !DocumentFileSource::can_read(biome_path) {
return Err(Message::from(
UnhandledDiagnostic.with_file_path(biome_path.to_string()),
));
diff --git a/crates/biome_cli/src/execute/traverse.rs b/crates/biome_cli/src/execute/traverse.rs
index e518413ec075..ae033573525a 100644
--- a/crates/biome_cli/src/execute/traverse.rs
+++ b/crates/biome_cli/src/execute/traverse.rs
@@ -13,7 +13,7 @@ use biome_fs::{BiomePath, FileSystem, PathInterner};
use biome_fs::{TraversalContext, TraversalScope};
use biome_service::dome::Dome;
use biome_service::projects::ProjectKey;
-use biome_service::workspace::{DropPatternParams, IsPathIgnoredParams};
+use biome_service::workspace::{DocumentFileSource, DropPatternParams, IsPathIgnoredParams};
use biome_service::{extension_error, workspace::SupportsFeatureParams, Workspace, WorkspaceError};
use camino::{Utf8Path, Utf8PathBuf};
use crossbeam::channel::{unbounded, Receiver, Sender};
@@ -596,7 +596,7 @@ impl TraversalContext for TraversalOptions<'_, '_> {
self.push_message(error);
}
- #[instrument(level = "debug", skip(self, biome_path))]
+ #[instrument(level = "trace", skip(self, biome_path), fields(can_handle))]
fn can_handle(&self, biome_path: &BiomePath) -> bool {
let path = biome_path.as_path();
if self.fs.path_is_dir(path) || self.fs.path_is_symlink(path) {
@@ -634,6 +634,8 @@ impl TraversalContext for TraversalOptions<'_, '_> {
features: self.execution.to_feature(),
});
+ let can_read = DocumentFileSource::can_read(biome_path);
+
let file_features = match file_features {
Ok(file_features) => {
if file_features.is_protected() {
@@ -642,7 +644,7 @@ impl TraversalContext for TraversalOptions<'_, '_> {
return false;
}
- if file_features.is_not_supported() && !file_features.is_ignored() {
+ if file_features.is_not_supported() && !file_features.is_ignored() && !can_read {
// we should throw a diagnostic if we can't handle a file that isn't ignored
self.miss_handler_err(extension_error(biome_path), biome_path);
Span::current().record("can_handle", false);
diff --git a/crates/biome_cli/tests/cases/mod.rs b/crates/biome_cli/tests/cases/mod.rs
index fc6f7361cd0b..6aa240d642f0 100644
--- a/crates/biome_cli/tests/cases/mod.rs
+++ b/crates/biome_cli/tests/cases/mod.rs
@@ -28,3 +28,4 @@ mod reporter_summary;
mod rules_via_dependencies;
mod suppressions;
mod unknown_files;
+mod vcs_ignored_files;
diff --git a/crates/biome_cli/tests/cases/vcs_ignored_files.rs b/crates/biome_cli/tests/cases/vcs_ignored_files.rs
new file mode 100644
index 000000000000..789e5ce85969
--- /dev/null
+++ b/crates/biome_cli/tests/cases/vcs_ignored_files.rs
@@ -0,0 +1,194 @@
+use crate::run_cli_with_dyn_fs;
+use crate::snap_test::{assert_cli_snapshot, SnapshotPayload};
+use biome_console::BufferConsole;
+use biome_fs::TemporaryFs;
+use bpaf::Args;
+
+const UNFORMATTED: &str = " statement( ) ";
+
+#[test]
+fn include_vcs_ignore_cascade() {
+ let mut console = BufferConsole::default();
+ let mut fs = TemporaryFs::new("include_vcs_ignore_cascade");
+
+ fs.create_file(".gitignore", r#"file4.js"#);
+ fs.create_file(
+ "biome.json",
+ r#"{
+ "vcs": {
+ "enabled": true,
+ "clientKind": "git",
+ "useIgnoreFile": true
+ },
+ "files": {
+ "includes": ["**", "!file2.js"]
+ },
+ "formatter": {
+ "includes": ["file1.js", "file2.js", "file4.js", "!file3.js"]
+ }
+ }"#,
+ );
+
+ // Only `file1.js` will be formatted:
+ // - `file2.js` is ignored at top-level
+ // - `file3.js` is ignored at formatter-level
+ // - `file4.js` is ignored in `.gitignore`
+ let files = [
+ ("file1.js", true),
+ ("file2.js", false),
+ ("file3.js", false),
+ ("file4.js", false),
+ ];
+ for (file_path, _) in files {
+ fs.create_file(file_path, UNFORMATTED);
+ }
+
+ let result = run_cli_with_dyn_fs(
+ Box::new(fs.create_os()),
+ &mut console,
+ Args::from(["format", fs.cli_path(), "--write"].as_slice()),
+ );
+ assert!(result.is_ok(), "run_cli returned {result:?}");
+
+ assert_cli_snapshot(SnapshotPayload::new(
+ module_path!(),
+ "include_vcs_ignore_cascade",
+ fs.create_mem(),
+ console,
+ result,
+ ));
+}
+
+#[test]
+fn ignore_vcs_os_independent_parse() {
+ let mut fs = TemporaryFs::new("ignore_vcs_os_independent_parse");
+ let mut console = BufferConsole::default();
+
+ fs.create_file(
+ "biome.json",
+ r#"{
+ "vcs": {
+ "enabled": true,
+ "clientKind": "git",
+ "useIgnoreFile": true
+ }
+ }"#,
+ );
+
+ fs.create_file(".gitignore", "something.js\nfile2.js\r\nfile3.js");
+
+ fs.create_file("file3.js", r#"console.log('biome is cool');"#);
+ fs.create_file("file2.js", r#"foo.call(); bar.call();"#);
+ fs.create_file("file1.js", r#"blah.call();"#);
+
+ let result = run_cli_with_dyn_fs(
+ Box::new(fs.create_os()),
+ &mut console,
+ Args::from(["check", "--write", fs.cli_path()].as_slice()),
+ );
+
+ assert!(result.is_ok(), "run_cli returned {result:?}");
+
+ assert_cli_snapshot(SnapshotPayload::new(
+ module_path!(),
+ "ignore_vcs_os_independent_parse",
+ fs.create_mem(),
+ console,
+ result,
+ ));
+}
+
+#[test]
+fn ignore_vcs_ignored_file_via_cli() {
+ let mut fs = TemporaryFs::new("ignore_vcs_ignored_file_via_cli");
+ let mut console = BufferConsole::default();
+
+ fs.create_file(
+ ".gitignore",
+ r#"
+file2.js
+"#,
+ );
+
+ fs.create_file("file2.js", r#"foo.call(); bar.call();"#);
+ fs.create_file(
+ "file1.js",
+ r#"array.map(sentence => sentence.split(' ')).flat();"#,
+ );
+
+ // git folder
+ fs.create_folder("git");
+
+ let result = run_cli_with_dyn_fs(
+ Box::new(fs.create_os()),
+ &mut console,
+ Args::from(
+ [
+ "lint",
+ "--vcs-enabled=true",
+ "--vcs-client-kind=git",
+ "--vcs-use-ignore-file=true",
+ "--vcs-root=.",
+ fs.cli_path(),
+ ]
+ .as_slice(),
+ ),
+ );
+
+ assert!(result.is_err(), "run_cli returned {result:?}");
+
+ assert_cli_snapshot(SnapshotPayload::new(
+ module_path!(),
+ "ignore_vcs_ignored_file_via_cli",
+ fs.create_mem(),
+ console,
+ result,
+ ));
+}
+
+#[test]
+fn ignores_file_inside_directory() {
+ let mut fs = TemporaryFs::new("ignores_file_inside_directory");
+ let mut console = BufferConsole::default();
+
+ fs.create_file(
+ ".gitignore",
+ r#"
+**/ignored/
+"#,
+ );
+
+ fs.create_file(
+ "ignored/file1.js",
+ r#"array.map(sentence => sentence.split(' ')).flat();"#,
+ );
+ fs.create_file("ignored/file2.js", r#"foo.call(); bar.call();"#);
+
+ let result = run_cli_with_dyn_fs(
+ Box::new(fs.create_os()),
+ &mut console,
+ Args::from(
+ [
+ "check",
+ "--vcs-enabled=true",
+ "--vcs-client-kind=git",
+ "--vcs-use-ignore-file=true",
+ "--vcs-root=.",
+ "--write",
+ "--unsafe",
+ fs.cli_path(),
+ ]
+ .as_slice(),
+ ),
+ );
+
+ assert!(result.is_err(), "run_cli returned {result:?}");
+
+ assert_cli_snapshot(SnapshotPayload::new(
+ module_path!(),
+ "ignores_file_inside_directory",
+ fs.create_mem(),
+ console,
+ result,
+ ));
+}
diff --git a/crates/biome_cli/tests/commands/check.rs b/crates/biome_cli/tests/commands/check.rs
index 4becfd5e3fb8..a54011167b85 100644
--- a/crates/biome_cli/tests/commands/check.rs
+++ b/crates/biome_cli/tests/commands/check.rs
@@ -1717,231 +1717,6 @@ fn ignore_configured_globals() {
));
}
-#[test]
-fn ignore_vcs_ignored_file() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let rome_json = r#"{
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": true
- }
- }"#;
-
- let git_ignore = r#"
-file2.js
-"#;
-
- let code2 = r#"foo.call(); bar.call();"#;
- let code1 = r#"array.map(sentence => sentence.split(' ')).flat();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // configuration
- let config_path = Utf8Path::new("biome.json");
- fs.insert(config_path.into(), rome_json.as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new(".gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(["check", file_path1.as_str(), file_path2.as_str()].as_slice()),
- );
-
- assert!(result.is_err(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_ignored_file",
- fs,
- console,
- result,
- ));
-}
-
-#[test]
-fn ignores_file_inside_directory() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let git_ignore = r#"
-ignored/**
-"#;
-
- let code1 = r#"array.map(sentence => sentence.split(' ')).flat();"#;
- let code2 = r#"foo.call(); bar.call();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("ignored/file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("ignored/file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // git folder
- let git_folder = Utf8Path::new("./.git");
- fs.insert(git_folder.into(), "".as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new("./.gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(
- [
- "check",
- "--vcs-enabled=true",
- "--vcs-client-kind=git",
- "--vcs-use-ignore-file=true",
- "--vcs-root=.",
- "--write",
- "--unsafe",
- file_path1.as_str(),
- file_path2.as_str(),
- ]
- .as_slice(),
- ),
- );
-
- assert_file_contents(&fs, file_path1, code1);
- assert_file_contents(&fs, file_path2, code2);
-
- assert!(result.is_err(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignores_file_inside_directory",
- fs,
- console,
- result,
- ));
-}
-
-#[test]
-fn ignore_vcs_os_independent_parse() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let rome_json = r#"{
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": true
- }
- }"#;
-
- let git_ignore = "something.js\nfile2.js\r\nfile3.js";
-
- let code3 = r#"console.log('biome is cool');"#;
- let code2 = r#"foo.call(); bar.call();"#;
- let code1 = r#"blah.call();"#;
-
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
-
- // ignored files
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
- let file_path3 = Utf8Path::new("file3.js");
- fs.insert(file_path3.into(), code3.as_bytes());
-
- // configuration
- let config_path = Utf8Path::new("biome.json");
- fs.insert(config_path.into(), rome_json.as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new(".gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(
- [
- "check",
- file_path1.as_str(),
- file_path2.as_str(),
- file_path3.as_str(),
- ]
- .as_slice(),
- ),
- );
-
- assert!(result.is_err(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_os_independent_parse",
- fs,
- console,
- result,
- ));
-}
-
-#[test]
-fn ignore_vcs_ignored_file_via_cli() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let git_ignore = r#"
-file2.js
-"#;
-
- let code2 = r#"foo.call(); bar.call();"#;
- let code1 = r#"array.map(sentence => sentence.split(' ')).flat();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // git folder
- let git_folder = Utf8Path::new("./.git");
- fs.insert(git_folder.into(), "".as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new("./.gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(
- [
- "check",
- "--vcs-enabled=true",
- "--vcs-client-kind=git",
- "--vcs-use-ignore-file=true",
- "--vcs-root=.",
- file_path1.as_str(),
- file_path2.as_str(),
- ]
- .as_slice(),
- ),
- );
-
- assert!(result.is_err(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_ignored_file_via_cli",
- fs,
- console,
- result,
- ));
-}
-
#[test]
fn check_stdin_write_successfully() {
let fs = MemoryFileSystem::default();
diff --git a/crates/biome_cli/tests/commands/ci.rs b/crates/biome_cli/tests/commands/ci.rs
index 24b1e7545134..348e097b805d 100644
--- a/crates/biome_cli/tests/commands/ci.rs
+++ b/crates/biome_cli/tests/commands/ci.rs
@@ -698,110 +698,6 @@ something( )
));
}
-#[test]
-fn ignore_vcs_ignored_file() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let rome_json = r#"{
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": true
- }
- }"#;
-
- let git_ignore = r#"
-file2.js
-"#;
-
- let code2 = r#"foo.call(); bar.call();"#;
- let code1 = r#"array.map(sentence => sentence.split(' ')).flat();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // configuration
- let config_path = Utf8Path::new("biome.json");
- fs.insert(config_path.into(), rome_json.as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new(".gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(["ci", file_path1.as_str(), file_path2.as_str()].as_slice()),
- );
-
- assert!(result.is_err(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_ignored_file",
- fs,
- console,
- result,
- ));
-}
-
-#[test]
-fn ignore_vcs_ignored_file_via_cli() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let git_ignore = r#"
-file2.js
-"#;
-
- let code2 = r#"foo.call();
-
-
- bar.call();"#;
- let code1 = r#"array.map(sentence => sentence.split(' ')).flat();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new("./.gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(
- [
- "ci",
- "--vcs-enabled=true",
- "--vcs-client-kind=git",
- "--vcs-use-ignore-file=true",
- "--vcs-root=.",
- file_path1.as_str(),
- file_path2.as_str(),
- ]
- .as_slice(),
- ),
- );
-
- assert!(result.is_err(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_ignored_file_via_cli",
- fs,
- console,
- result,
- ));
-}
-
#[test]
fn ignores_unknown_file() {
let mut fs = MemoryFileSystem::default();
diff --git a/crates/biome_cli/tests/commands/format.rs b/crates/biome_cli/tests/commands/format.rs
index 23ece875fd5f..dbe3f73f1846 100644
--- a/crates/biome_cli/tests/commands/format.rs
+++ b/crates/biome_cli/tests/commands/format.rs
@@ -1813,195 +1813,6 @@ fn print_verbose() {
));
}
-#[test]
-fn ignore_vcs_ignored_file() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let rome_json = r#"{
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": true
- }
- }"#;
-
- let git_ignore = r#"
-file2.js
-"#;
-
- let code2 = r#"foo.call();
-
-
- bar.call();"#;
- let code1 = r#"array.map(sentence =>
-
-
- sentence.split(' ')).flat();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // configuration
- let config_path = Utf8Path::new("biome.json");
- fs.insert(config_path.into(), rome_json.as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new(".gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(
- [
- "format",
- "--write",
- file_path1.as_str(),
- file_path2.as_str(),
- ]
- .as_slice(),
- ),
- );
-
- assert!(result.is_ok(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_ignored_file",
- fs,
- console,
- result,
- ));
-}
-
-#[test]
-fn ignore_vcs_ignored_file_via_cli() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let git_ignore = r#"
-file2.js
-"#;
-
- let code2 = r#"foo.call();
-
-
- bar.call();"#;
- let code1 = r#"array.map(sentence =>
-
-
- sentence.split(' ')).flat();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // git folder
- let git_folder = Utf8Path::new("./.git");
- fs.insert(git_folder.into(), "".as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new("./.gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(
- [
- "format",
- "--vcs-enabled=true",
- "--vcs-client-kind=git",
- "--vcs-use-ignore-file=true",
- "--vcs-root=.",
- "--write",
- file_path1.as_str(),
- file_path2.as_str(),
- ]
- .as_slice(),
- ),
- );
-
- assert!(result.is_ok(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_ignored_file_via_cli",
- fs,
- console,
- result,
- ));
-}
-
-#[test]
-fn include_vcs_ignore_cascade() {
- // Only `file1.js` will be formatted:
- // - `file2.js` is ignored at top-level
- // - `file3.js` is ignored at formatter-level
- // - `file4.js` is ignored in `.gitignore`
- let git_ignore = r#"file4.js"#;
- let config = r#"{
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": true
- },
- "files": {
- "includes": ["**", "!file2.js"]
- },
- "formatter": {
- "includes": ["file1.js", "file2.js", "file4.js", "!file3.js"]
- }
- }"#;
- let files = [
- ("file1.js", true),
- ("file2.js", false),
- ("file3.js", false),
- ("file4.js", false),
- ];
-
- let mut console = BufferConsole::default();
- let mut fs = MemoryFileSystem::default();
- let gitignore_file = Utf8Path::new(".gitignore");
- fs.insert(gitignore_file.into(), git_ignore.as_bytes());
- let file_path = Utf8Path::new("biome.json");
- fs.insert(file_path.into(), config);
- for (file_path, _) in files {
- let file_path = Utf8Path::new(file_path);
- fs.insert(file_path.into(), UNFORMATTED.as_bytes());
- }
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(["format", ".", "--write"].as_slice()),
- );
- assert!(result.is_ok(), "run_cli returned {result:?}");
-
- for (file_path, expect_formatted) in files {
- let expected = if expect_formatted {
- FORMATTED
- } else {
- UNFORMATTED
- };
- assert_file_contents(&fs, Utf8Path::new(file_path), expected);
- }
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "include_vcs_ignore_cascade",
- fs,
- console,
- result,
- ));
-}
-
#[test]
fn vcs_absolute_path() {
let git_ignore = r#"file.js"#;
@@ -3265,7 +3076,7 @@ fn format_empty_svelte_ts_files_write() {
let mut console = BufferConsole::default();
let svelte_file_path = Utf8Path::new("file.svelte");
- fs.insert(svelte_file_path.into(), "
".as_bytes());
+ fs.insert(svelte_file_path.into(), "".as_bytes());
let (fs, result) = run_cli(
fs,
@@ -3275,7 +3086,7 @@ fn format_empty_svelte_ts_files_write() {
assert!(result.is_ok(), "run_cli returned {result:?}");
- assert_file_contents(&fs, svelte_file_path, "");
+ assert_file_contents(&fs, svelte_file_path, "");
assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs
index ebacda4823cd..661a03169c61 100644
--- a/crates/biome_cli/tests/commands/lint.rs
+++ b/crates/biome_cli/tests/commands/lint.rs
@@ -1716,172 +1716,6 @@ fn ignore_configured_globals() {
));
}
-#[test]
-fn ignore_vcs_ignored_file() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let rome_json = r#"{
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": true
- }
- }"#;
-
- let git_ignore = r#"
-file2.js
-"#;
-
- let code2 = r#"foo.call(); bar.call();"#;
- let code1 = r#"array.map(sentence => sentence.split(' ')).flat();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // configuration
- let config_path = Utf8Path::new("biome.json");
- fs.insert(config_path.into(), rome_json.as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new(".gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(["lint", file_path1.as_str(), file_path2.as_str()].as_slice()),
- );
-
- assert!(result.is_err(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_ignored_file",
- fs,
- console,
- result,
- ));
-}
-
-#[test]
-fn ignore_vcs_os_independent_parse() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let rome_json = r#"{
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": true
- }
- }"#;
-
- let git_ignore = "something.js\nfile2.js\r\nfile3.js";
-
- let code3 = r#"console.log('biome is cool');"#;
- let code2 = r#"foo.call(); bar.call();"#;
- let code1 = r#"blah.call();"#;
-
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
-
- // ignored files
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
- let file_path3 = Utf8Path::new("file3.js");
- fs.insert(file_path3.into(), code3.as_bytes());
-
- // configuration
- let config_path = Utf8Path::new("biome.json");
- fs.insert(config_path.into(), rome_json.as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new(".gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(
- [
- "lint",
- file_path1.as_str(),
- file_path2.as_str(),
- file_path3.as_str(),
- ]
- .as_slice(),
- ),
- );
-
- assert!(result.is_ok(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_os_independent_parse",
- fs,
- console,
- result,
- ));
-}
-
-#[test]
-fn ignore_vcs_ignored_file_via_cli() {
- let mut fs = MemoryFileSystem::default();
- let mut console = BufferConsole::default();
-
- let git_ignore = r#"
-file2.js
-"#;
-
- let code2 = r#"foo.call(); bar.call();"#;
- let code1 = r#"array.map(sentence => sentence.split(' ')).flat();"#;
-
- // ignored files
- let file_path1 = Utf8Path::new("file1.js");
- fs.insert(file_path1.into(), code1.as_bytes());
- let file_path2 = Utf8Path::new("file2.js");
- fs.insert(file_path2.into(), code2.as_bytes());
-
- // git folder
- let git_folder = Utf8Path::new("./.git");
- fs.insert(git_folder.into(), "".as_bytes());
-
- // git ignore file
- let ignore_file = Utf8Path::new("./.gitignore");
- fs.insert(ignore_file.into(), git_ignore.as_bytes());
-
- let (fs, result) = run_cli(
- fs,
- &mut console,
- Args::from(
- [
- "lint",
- "--vcs-enabled=true",
- "--vcs-client-kind=git",
- "--vcs-use-ignore-file=true",
- "--vcs-root=.",
- file_path1.as_str(),
- file_path2.as_str(),
- ]
- .as_slice(),
- ),
- );
-
- assert!(result.is_err(), "run_cli returned {result:?}");
-
- assert_cli_snapshot(SnapshotPayload::new(
- module_path!(),
- "ignore_vcs_ignored_file_via_cli",
- fs,
- console,
- result,
- ));
-}
-
#[test]
fn check_stdin_write_successfully() {
let fs = MemoryFileSystem::default();
diff --git a/crates/biome_cli/tests/snapshots/main_cases_config_path/raises_a_warning_for_double_configuration_found.snap b/crates/biome_cli/tests/snapshots/main_cases_config_path/raises_a_warning_for_double_configuration_found.snap
deleted file mode 100644
index 85cc58e16ca8..000000000000
--- a/crates/biome_cli/tests/snapshots/main_cases_config_path/raises_a_warning_for_double_configuration_found.snap
+++ /dev/null
@@ -1,52 +0,0 @@
----
-source: crates/biome_cli/tests/snap_test.rs
-expression: redactor(content)
-snapshot_kind: text
----
-## `biome.jsonc`
-
-```json
-{}
-```
-
-## `file.js`
-
-```js
-function name() { return "lorem" }
-```
-
-# Termination Message
-
-```block
-check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
- × Some errors were emitted while running checks.
-
-
-
-```
-
-# Emitted Messages
-
-```block
-Both biome.json and biome.jsonc files were found in the same folder. Biome will use the biome.json file.
-```
-
-```block
-file.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
- × Formatter would have printed the following content:
-
- 1 │ - function·name()·{·return·"lorem"·}
- 1 │ + function·name()·{
- 2 │ + ········return·"lorem";
- 3 │ + }
- 4 │ +
-
-
-```
-
-```block
-Checked 1 file in