diff --git a/crates/biome_cli/tests/cases/assist.rs b/crates/biome_cli/tests/cases/assist.rs index 2ef595ed313f..fe150cf6b45f 100644 --- a/crates/biome_cli/tests/cases/assist.rs +++ b/crates/biome_cli/tests/cases/assist.rs @@ -35,7 +35,7 @@ fn assist_emit_diagnostic() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -79,7 +79,7 @@ fn assist_writes() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/biome_json_support.rs b/crates/biome_cli/tests/cases/biome_json_support.rs index da975127d75f..830268fb1e85 100644 --- a/crates/biome_cli/tests/cases/biome_json_support.rs +++ b/crates/biome_cli/tests/cases/biome_json_support.rs @@ -42,7 +42,7 @@ fn formatter_biome_json() { "--indent-width", "8", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -87,7 +87,7 @@ fn linter_biome_json() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -136,7 +136,7 @@ fn check_biome_json() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -181,7 +181,7 @@ fn ci_biome_json() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", input_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", input_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/config_extends.rs b/crates/biome_cli/tests/cases/config_extends.rs index 9b985e9a273a..5b0b3eb2bd46 100644 --- a/crates/biome_cli/tests/cases/config_extends.rs +++ b/crates/biome_cli/tests/cases/config_extends.rs @@ -30,7 +30,7 @@ fn extends_config_ok_formatter_no_linter() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", test_file.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -77,7 +77,7 @@ fn extends_config_ok_linter_not_formatter() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", test_file.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -115,7 +115,7 @@ fn extends_should_raise_an_error_for_unresolved_configuration() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", test_file.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -153,14 +153,7 @@ fn extends_should_raise_an_error_for_unresolved_configuration_and_show_verbose() let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--verbose", - test_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--verbose", test_file.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -198,14 +191,7 @@ fn extends_resolves_when_using_config_path() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--config-path=config/", - test_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--config-path=config/", test_file.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -245,7 +231,7 @@ fn applies_extended_values_in_current_config() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", test_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -282,7 +268,7 @@ fn respects_unaffected_values_from_extended_config() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", test_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -322,7 +308,7 @@ fn allows_reverting_fields_in_extended_config_to_default() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", test_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -370,7 +356,7 @@ fn extends_config_merge_overrides() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", test_file.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( diff --git a/crates/biome_cli/tests/cases/cts_files.rs b/crates/biome_cli/tests/cases/cts_files.rs index 5396f928d638..e2b6bffd5d0c 100644 --- a/crates/biome_cli/tests/cases/cts_files.rs +++ b/crates/biome_cli/tests/cases/cts_files.rs @@ -19,7 +19,7 @@ fn should_allow_using_export_statements() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/diagnostics.rs b/crates/biome_cli/tests/cases/diagnostics.rs index c9bdce4ef856..1f8e9e746a10 100644 --- a/crates/biome_cli/tests/cases/diagnostics.rs +++ b/crates/biome_cli/tests/cases/diagnostics.rs @@ -37,14 +37,7 @@ fn logs_the_appropriate_messages_according_to_set_diagnostics_level() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--diagnostic-level=error", - test.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--diagnostic-level=error", test.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -213,15 +206,7 @@ fn max_diagnostics_are_lifted() { let (mut fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - "--max-diagnostics", - "none", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", "--max-diagnostics", "none", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/editorconfig.rs b/crates/biome_cli/tests/cases/editorconfig.rs index 8b761745579f..81252108928e 100644 --- a/crates/biome_cli/tests/cases/editorconfig.rs +++ b/crates/biome_cli/tests/cases/editorconfig.rs @@ -32,7 +32,7 @@ max_line_length = 300 "format", "--write", "--use-editorconfig=true", - test_file.as_os_str().to_str().unwrap(), + test_file.as_str(), ] .as_slice(), ), @@ -83,7 +83,7 @@ max_line_length = 300 let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", test_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -120,14 +120,7 @@ max_line_length = 300 let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--use-editorconfig=true", - test_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--use-editorconfig=true", test_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -175,7 +168,7 @@ max_line_length = 300 let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", test_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -231,7 +224,7 @@ indent_style = tab "format", "--write", "--use-editorconfig=true", - test_file.as_os_str().to_str().unwrap(), + test_file.as_str(), ] .as_slice(), ), @@ -275,7 +268,7 @@ max_line_length = 90 "check", "--line-width=100", "--use-editorconfig=true", - test_file.as_os_str().to_str().unwrap(), + test_file.as_str(), ] .as_slice(), ), @@ -335,8 +328,8 @@ indent_style = space [ "check", "--use-editorconfig=true", - test_file.as_os_str().to_str().unwrap(), - test_file2.as_os_str().to_str().unwrap(), + test_file.as_str(), + test_file2.as_str(), ] .as_slice(), ), @@ -375,14 +368,7 @@ max_line_length = 300 let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - "--use-editorconfig=true", - test_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", "--use-editorconfig=true", test_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -430,7 +416,7 @@ max_line_length = 300 let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", test_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", test_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -472,7 +458,7 @@ insert_final_newline = false "format", "--write", "--use-editorconfig=true", - test_file.as_os_str().to_str().unwrap(), + test_file.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/cases/graphql.rs b/crates/biome_cli/tests/cases/graphql.rs index 007dd736efc3..270a687ff49a 100644 --- a/crates/biome_cli/tests/cases/graphql.rs +++ b/crates/biome_cli/tests/cases/graphql.rs @@ -31,7 +31,7 @@ fn format_graphql_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -58,7 +58,7 @@ fn format_and_write_graphql_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -89,7 +89,7 @@ fn lint_single_rule() { [ "lint", "--only=nursery/useDeprecatedReason", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/cases/handle_astro_files.rs b/crates/biome_cli/tests/cases/handle_astro_files.rs index b3b7901cd6bc..26c9f9e54c74 100644 --- a/crates/biome_cli/tests/cases/handle_astro_files.rs +++ b/crates/biome_cli/tests/cases/handle_astro_files.rs @@ -82,7 +82,7 @@ fn format_astro_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", astro_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", astro_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -107,14 +107,7 @@ fn format_astro_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - astro_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", astro_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -139,14 +132,7 @@ fn format_empty_astro_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - astro_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", astro_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -174,7 +160,7 @@ fn format_astro_carriage_return_line_feed_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", astro_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", astro_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -202,7 +188,7 @@ fn lint_astro_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", astro_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", astro_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -230,15 +216,7 @@ fn lint_and_fix_astro_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--unsafe", - astro_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--unsafe", astro_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -268,7 +246,7 @@ fn sorts_imports_check() { "check", "--formatter-enabled=false", "--linter-enabled=false", - astro_file_path.as_os_str().to_str().unwrap(), + astro_file_path.as_str(), ] .as_slice(), ), @@ -302,7 +280,7 @@ fn sorts_imports_write() { "--formatter-enabled=false", "--linter-enabled=false", "--write", - astro_file_path.as_os_str().to_str().unwrap(), + astro_file_path.as_str(), ] .as_slice(), ), @@ -330,7 +308,7 @@ fn does_not_throw_parse_error_for_return() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", astro_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", astro_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -640,7 +618,7 @@ fn astro_global_object() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", astro_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", astro_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/handle_css_files.rs b/crates/biome_cli/tests/cases/handle_css_files.rs index 9c221ff05204..981d4bf2fc69 100644 --- a/crates/biome_cli/tests/cases/handle_css_files.rs +++ b/crates/biome_cli/tests/cases/handle_css_files.rs @@ -17,7 +17,7 @@ fn should_not_format_files_by_default() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", css_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", css_file.as_str()].as_slice()), ); // no files processed error @@ -44,14 +44,7 @@ fn should_format_files_by_when_opt_in() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--css-formatter-enabled=true", - css_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--css-formatter-enabled=true", css_file.as_str()].as_slice()), ); // not formatted error @@ -83,7 +76,7 @@ fn should_format_write_files_by_when_opt_in() { "format", "--write", "--css-formatter-enabled=true", - css_file.as_os_str().to_str().unwrap(), + css_file.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/cases/handle_svelte_files.rs b/crates/biome_cli/tests/cases/handle_svelte_files.rs index c9e9db1225d6..bc05e84e38c5 100644 --- a/crates/biome_cli/tests/cases/handle_svelte_files.rs +++ b/crates/biome_cli/tests/cases/handle_svelte_files.rs @@ -65,7 +65,7 @@ fn sorts_imports_check() { "check", "--formatter-enabled=false", "--linter-enabled=false", - svelte_file_path.as_os_str().to_str().unwrap(), + svelte_file_path.as_str(), ] .as_slice(), ), @@ -104,7 +104,7 @@ fn sorts_imports_write() { "--formatter-enabled=false", "--linter-enabled=false", "--write", - svelte_file_path.as_os_str().to_str().unwrap(), + svelte_file_path.as_str(), ] .as_slice(), ), @@ -137,7 +137,7 @@ fn format_svelte_ts_context_module_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", svelte_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -171,14 +171,7 @@ fn format_svelte_ts_context_module_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - svelte_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -212,7 +205,7 @@ fn format_svelte_carriage_return_line_feed_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", svelte_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/handle_vue_files.rs b/crates/biome_cli/tests/cases/handle_vue_files.rs index a5afba258df1..9a16660834b1 100644 --- a/crates/biome_cli/tests/cases/handle_vue_files.rs +++ b/crates/biome_cli/tests/cases/handle_vue_files.rs @@ -120,7 +120,7 @@ fn format_vue_implicit_js_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", vue_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", vue_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -150,14 +150,7 @@ fn format_vue_implicit_js_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - vue_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", vue_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -187,7 +180,7 @@ fn format_vue_explicit_js_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", vue_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", vue_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -217,14 +210,7 @@ fn format_vue_explicit_js_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - vue_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", vue_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -251,14 +237,7 @@ fn format_empty_vue_js_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - vue_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", vue_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -285,7 +264,7 @@ fn format_vue_ts_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", vue_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", vue_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -312,14 +291,7 @@ fn format_vue_ts_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - vue_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", vue_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -346,14 +318,7 @@ fn format_empty_vue_ts_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - vue_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", vue_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -383,7 +348,7 @@ fn format_vue_carriage_return_line_feed_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", vue_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", vue_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -417,7 +382,7 @@ fn format_vue_generic_component_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", vue_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", vue_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -444,7 +409,7 @@ fn lint_vue_js_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", vue_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", vue_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -469,7 +434,7 @@ fn lint_vue_ts_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", vue_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", vue_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -499,7 +464,7 @@ fn sorts_imports_check() { "check", "--formatter-enabled=false", "--linter-enabled=false", - vue_file_path.as_os_str().to_str().unwrap(), + vue_file_path.as_str(), ] .as_slice(), ), @@ -535,7 +500,7 @@ fn sorts_imports_write() { "--formatter-enabled=false", "--linter-enabled=false", "--write", - vue_file_path.as_os_str().to_str().unwrap(), + vue_file_path.as_str(), ] .as_slice(), ), @@ -775,7 +740,7 @@ fn vue_compiler_macros_as_globals() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", vue_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", vue_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/included_files.rs b/crates/biome_cli/tests/cases/included_files.rs index c5c1fc18f374..2d432cf7f7a9 100644 --- a/crates/biome_cli/tests/cases/included_files.rs +++ b/crates/biome_cli/tests/cases/included_files.rs @@ -39,15 +39,7 @@ fn does_handle_only_included_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -88,15 +80,7 @@ fn does_not_handle_included_files_if_overridden_by_ignore() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -137,15 +121,7 @@ fn does_not_handle_included_files_if_overridden_by_ignore_formatter() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -186,15 +162,7 @@ fn does_not_handle_included_files_if_overridden_by_ignore_linter() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -237,15 +205,7 @@ fn does_not_handle_included_files_if_overridden_by_organize_imports() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/linter_domains.rs b/crates/biome_cli/tests/cases/linter_domains.rs index 589baf43320c..5412862c529f 100644 --- a/crates/biome_cli/tests/cases/linter_domains.rs +++ b/crates/biome_cli/tests/cases/linter_domains.rs @@ -47,14 +47,7 @@ describe("foo", () => { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", test1.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -108,14 +101,7 @@ describe("foo", () => { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", test1.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -177,14 +163,7 @@ describe("foo", () => { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", test1.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -241,8 +220,8 @@ describe("foo", () => { Args::from( [ "lint", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), + test1.as_str(), + test2.as_str(), "--skip=suspicious/noDuplicateTestHooks", ] .as_slice(), @@ -305,8 +284,8 @@ describe("foo", () => { Args::from( [ "lint", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), + test1.as_str(), + test2.as_str(), "--only=suspicious/noDebugger", ] .as_slice(), diff --git a/crates/biome_cli/tests/cases/overrides_formatter.rs b/crates/biome_cli/tests/cases/overrides_formatter.rs index e98d6e5ed4d6..91697c913bb1 100644 --- a/crates/biome_cli/tests/cases/overrides_formatter.rs +++ b/crates/biome_cli/tests/cases/overrides_formatter.rs @@ -55,15 +55,7 @@ fn does_handle_included_file_and_disable_formatter() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -104,15 +96,7 @@ fn does_include_file_with_different_formatting() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -156,15 +140,7 @@ fn does_include_file_with_different_formatting_and_all_of_them() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -208,15 +184,7 @@ fn does_include_file_with_different_overrides() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -282,8 +250,8 @@ fn complex_enable_disable_overrides() { [ "format", "--write", - formatted.as_os_str().to_str().unwrap(), - unformatted.as_os_str().to_str().unwrap(), + formatted.as_str(), + unformatted.as_str(), ] .as_slice(), ), @@ -334,9 +302,9 @@ fn does_include_file_with_different_languages() { [ "format", "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - test_css.as_os_str().to_str().unwrap(), + test.as_str(), + test2.as_str(), + test_css.as_str(), ] .as_slice(), ), @@ -405,10 +373,10 @@ fn does_include_file_with_different_languages_and_files() { [ "format", "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - json_file.as_os_str().to_str().unwrap(), - css_file.as_os_str().to_str().unwrap(), + test.as_str(), + test2.as_str(), + json_file.as_str(), + css_file.as_str(), ] .as_slice(), ), @@ -457,15 +425,7 @@ fn does_not_change_formatting_settings() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -509,15 +469,7 @@ fn does_not_change_formatting_language_settings() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -561,15 +513,7 @@ fn does_not_change_formatting_language_settings_2() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -612,14 +556,7 @@ fn does_not_conceal_previous_overrides() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", test.as_str(), test2.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -658,7 +595,7 @@ fn takes_last_formatter_enabled_into_account() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", test.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", test.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -710,14 +647,7 @@ fn does_not_override_well_known_special_files_when_config_override_is_present() let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - other_json.as_os_str().to_str().unwrap(), - tsconfig.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", other_json.as_str(), tsconfig.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -785,15 +715,7 @@ fn allow_trailing_commas_on_well_known_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - other_json.as_os_str().to_str().unwrap(), - tsconfig.as_os_str().to_str().unwrap(), - ".vscode/", - ] - .as_slice(), - ), + Args::from(["check", other_json.as_str(), tsconfig.as_str(), ".vscode/"].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -841,7 +763,7 @@ fn disallow_comments_on_well_known_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", tsconfig.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", tsconfig.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -852,3 +774,50 @@ fn disallow_comments_on_well_known_files() { result, )); } + +#[test] +fn overrides_grit_formatting_options() { + let mut console = BufferConsole::default(); + let mut fs = MemoryFileSystem::default(); + let file_path = Utf8Path::new("biome.json"); + fs.insert( + file_path.into(), + r#"{ + "formatter": { + "indentStyle": "tab" + }, + "overrides": [ + { + "include": [ + "file.grit" + ], + "grit": { "formatter": { "indentStyle": "space", "indentWidth": 8 } } + } + ] + }"# + .as_bytes(), + ); + + let js_file = Utf8Path::new("file.js"); + fs.insert(js_file.into(), r#"function name() { return "hello"; }"#); + + let grit_file = Utf8Path::new("file.grit"); + fs.insert( + grit_file.into(), + r#"`console.$_($content)` where { $content <: contains `secret` until `sanitized($_)` }"#, + ); + + let (fs, result) = run_cli( + fs, + &mut console, + Args::from(["format", js_file.as_str(), grit_file.as_str()].as_slice()), + ); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "overrides_grit_formatting_options", + fs, + console, + result, + )); +} diff --git a/crates/biome_cli/tests/cases/overrides_linter.rs b/crates/biome_cli/tests/cases/overrides_linter.rs index 11b2fa31515d..0aafb8d2146b 100644 --- a/crates/biome_cli/tests/cases/overrides_linter.rs +++ b/crates/biome_cli/tests/cases/overrides_linter.rs @@ -41,15 +41,7 @@ fn does_handle_included_file_and_disable_linter() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -92,16 +84,7 @@ fn does_include_file_with_different_rules() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--unsafe", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--unsafe", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -167,16 +150,7 @@ fn does_include_file_with_different_linting_and_applies_all_of_them() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--unsafe", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--unsafe", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -242,16 +216,7 @@ fn does_include_file_with_different_overrides() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--unsafe", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--unsafe", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -305,16 +270,7 @@ fn does_override_the_rules() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--unsafe", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--unsafe", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -364,16 +320,7 @@ fn does_not_change_linting_settings() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--unsafe", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--unsafe", test.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/overrides_organize_imports.rs b/crates/biome_cli/tests/cases/overrides_organize_imports.rs index 55db41f7bf8b..4db99c26475b 100644 --- a/crates/biome_cli/tests/cases/overrides_organize_imports.rs +++ b/crates/biome_cli/tests/cases/overrides_organize_imports.rs @@ -43,8 +43,8 @@ fn does_handle_included_file_and_disable_organize_imports() { "--write", "--formatter-enabled=false", "--linter-enabled=false", - test.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), + test.as_str(), + test2.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/cases/protected_files.rs b/crates/biome_cli/tests/cases/protected_files.rs index 152dedab952c..48bc03e96db8 100644 --- a/crates/biome_cli/tests/cases/protected_files.rs +++ b/crates/biome_cli/tests/cases/protected_files.rs @@ -112,7 +112,7 @@ fn not_process_file_from_cli() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -137,14 +137,7 @@ fn not_process_file_from_cli_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--verbose", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -178,14 +171,7 @@ fn not_process_ignored_file_from_cli_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--verbose", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -219,14 +205,7 @@ fn not_process_file_linter_disabled_from_cli_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--verbose", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/reporter_github.rs b/crates/biome_cli/tests/cases/reporter_github.rs index 420a03372e26..41d18f5b7151 100644 --- a/crates/biome_cli/tests/cases/reporter_github.rs +++ b/crates/biome_cli/tests/cases/reporter_github.rs @@ -43,8 +43,8 @@ fn reports_diagnostics_github_check_command() { [ "check", "--reporter=github", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -79,8 +79,8 @@ fn reports_diagnostics_github_ci_command() { [ "ci", "--reporter=github", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -115,8 +115,8 @@ fn reports_diagnostics_github_lint_command() { [ "lint", "--reporter=github", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -151,8 +151,8 @@ fn reports_diagnostics_github_format_command() { [ "format", "--reporter=github", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/cases/reporter_gitlab.rs b/crates/biome_cli/tests/cases/reporter_gitlab.rs index 5fb3cdd45776..076594244d70 100644 --- a/crates/biome_cli/tests/cases/reporter_gitlab.rs +++ b/crates/biome_cli/tests/cases/reporter_gitlab.rs @@ -64,8 +64,8 @@ fn reports_diagnostics_gitlab_check_command() { "check", "--reporter=gitlab", "--max-diagnostics=200", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -101,8 +101,8 @@ fn reports_diagnostics_gitlab_ci_command() { "ci", "--reporter=gitlab", "--max-diagnostics=200", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -138,8 +138,8 @@ fn reports_diagnostics_gitlab_lint_command() { "lint", "--reporter=gitlab", "--max-diagnostics=200", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -175,8 +175,8 @@ fn reports_diagnostics_gitlab_format_command() { "format", "--reporter=gitlab", "--max-diagnostics=200", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/cases/reporter_junit.rs b/crates/biome_cli/tests/cases/reporter_junit.rs index ab58080f6ece..2be8a460ecfb 100644 --- a/crates/biome_cli/tests/cases/reporter_junit.rs +++ b/crates/biome_cli/tests/cases/reporter_junit.rs @@ -43,8 +43,8 @@ fn reports_diagnostics_junit_check_command() { [ "check", "--reporter=junit", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -79,8 +79,8 @@ fn reports_diagnostics_junit_ci_command() { [ "ci", "--reporter=junit", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -115,8 +115,8 @@ fn reports_diagnostics_junit_lint_command() { [ "lint", "--reporter=junit", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -151,8 +151,8 @@ fn reports_diagnostics_junit_format_command() { [ "format", "--reporter=junit", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/cases/reporter_summary.rs b/crates/biome_cli/tests/cases/reporter_summary.rs index 0f07005bed5e..3a72cdb60a97 100644 --- a/crates/biome_cli/tests/cases/reporter_summary.rs +++ b/crates/biome_cli/tests/cases/reporter_summary.rs @@ -77,9 +77,9 @@ fn reports_diagnostics_summary_check_command() { "check", "--reporter=summary", "--max-diagnostics=200", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), + file_path3.as_str(), ] .as_slice(), ), @@ -118,9 +118,9 @@ fn reports_diagnostics_summary_ci_command() { "ci", "--reporter=summary", "--max-diagnostics=200", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), + file_path3.as_str(), ] .as_slice(), ), @@ -159,9 +159,9 @@ fn reports_diagnostics_summary_lint_command() { "lint", "--reporter=summary", "--max-diagnostics=200", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), + file_path3.as_str(), ] .as_slice(), ), @@ -200,9 +200,9 @@ fn reports_diagnostics_summary_format_command() { "format", "--reporter=summary", "--max-diagnostics=200", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), + file_path3.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/cases/rules_via_dependencies.rs b/crates/biome_cli/tests/cases/rules_via_dependencies.rs index c4937f67832f..5bc9c3d72748 100644 --- a/crates/biome_cli/tests/cases/rules_via_dependencies.rs +++ b/crates/biome_cli/tests/cases/rules_via_dependencies.rs @@ -39,7 +39,7 @@ function Component2() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", test.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", test.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -86,7 +86,7 @@ describe("foo", () => { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", test.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", test.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -148,7 +148,7 @@ function Component2() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", test.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", test.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/suppressions.rs b/crates/biome_cli/tests/cases/suppressions.rs index 305b37e9ecd2..c740d7d4b094 100644 --- a/crates/biome_cli/tests/cases/suppressions.rs +++ b/crates/biome_cli/tests/cases/suppressions.rs @@ -23,14 +23,7 @@ fn ok() { let (_, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--suppress", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--suppress", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -47,15 +40,7 @@ fn err_when_both_write_and_suppress_are_passed() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--suppress", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--suppress", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -79,14 +64,7 @@ fn suppress_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--suppress", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--suppress", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -122,14 +100,7 @@ fn suppress_multiple_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--suppress", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--suppress", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -167,7 +138,7 @@ fn suppress_only_ok() { "lint", "--suppress", "--only=lint/suspicious/noCompareNegZero", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -208,7 +179,7 @@ fn suppress_skip_ok() { "lint", "--suppress", "--skip=lint/suspicious/noCompareNegZero", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -244,7 +215,7 @@ fn err_when_only_reason() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--reason", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--reason", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -282,7 +253,7 @@ fn custom_explanation_with_reason() { "lint", "--suppress", "--reason=We love Biome", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -330,7 +301,7 @@ let bar = 33;", let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -365,7 +336,7 @@ let bar = 33;", let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -399,7 +370,7 @@ a == b; let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/cases/unknown_files.rs b/crates/biome_cli/tests/cases/unknown_files.rs index 7a1f96211b11..dcd0381f0baf 100644 --- a/crates/biome_cli/tests/cases/unknown_files.rs +++ b/crates/biome_cli/tests/cases/unknown_files.rs @@ -19,14 +19,7 @@ fn should_print_a_diagnostic_unknown_file() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", file_path1.as_str(), file_path2.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -60,14 +53,7 @@ fn should_not_print_a_diagnostic_unknown_file_because_ignored() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", file_path1.as_str(), file_path2.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/commands/check.rs b/crates/biome_cli/tests/commands/check.rs index 5ee71212e090..116215e4a8be 100644 --- a/crates/biome_cli/tests/commands/check.rs +++ b/crates/biome_cli/tests/commands/check.rs @@ -85,7 +85,7 @@ fn ok() { let (_, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -102,7 +102,7 @@ fn ok_read_only() { let (_, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -119,7 +119,7 @@ fn parse_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -143,7 +143,7 @@ fn lint_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -167,7 +167,7 @@ fn maximum_diagnostics() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -212,7 +212,7 @@ fn apply_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -245,7 +245,7 @@ fn apply_noop() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -270,15 +270,7 @@ fn apply_suggested_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--unsafe", - "--write", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--unsafe", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -303,15 +295,7 @@ fn apply_suggested() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--write", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--write", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -364,8 +348,8 @@ function f() {\n\targuments;\n} "check", "--write", "--unsafe", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), + test1.as_str(), + test2.as_str(), ] .as_slice(), ), @@ -399,7 +383,7 @@ fn no_lint_if_linter_is_disabled_when_run_apply() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -435,7 +419,7 @@ fn no_lint_if_linter_is_disabled_when_run_apply_biome_jsonc() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -471,7 +455,7 @@ fn no_lint_if_linter_is_disabled() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -507,7 +491,7 @@ fn should_disable_a_rule() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -546,7 +530,7 @@ fn should_disable_a_rule_group() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -584,7 +568,7 @@ fn downgrade_severity() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -628,7 +612,7 @@ fn upgrade_severity() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -673,7 +657,7 @@ fn no_lint_when_file_is_ignored() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -728,8 +712,8 @@ fn no_lint_if_files_are_listed_in_ignore_option() { [ "check", "--write", - file_path_test1.as_os_str().to_str().unwrap(), - file_path_test2.as_os_str().to_str().unwrap(), + file_path_test1.as_str(), + file_path_test2.as_str(), ] .as_slice(), ), @@ -924,7 +908,7 @@ fn fs_error_read_only() { let (mut fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1098,7 +1082,7 @@ fn file_too_large() { let (mut fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1128,7 +1112,7 @@ fn file_too_large_config_limit() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1153,14 +1137,7 @@ fn file_too_large_cli_limit() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--files-max-size=16", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--files-max-size=16", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1185,14 +1162,7 @@ fn files_max_size_parse_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--files-max-size=-1", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--files-max-size=-1", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1265,7 +1235,7 @@ fn max_diagnostics() { "check", "--max-diagnostics", "10", - Utf8Path::new("src").as_os_str().to_str().unwrap(), + Utf8Path::new("src").as_str(), ] .as_slice(), ), @@ -1327,14 +1297,7 @@ fn print_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--verbose", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1359,15 +1322,7 @@ fn print_verbose_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--verbose", - "--write", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--verbose", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1392,7 +1347,7 @@ fn unsupported_file() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1416,14 +1371,7 @@ fn unsupported_file_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--verbose", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1447,7 +1395,7 @@ fn suppression_syntax_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1475,7 +1423,7 @@ fn config_recommended_group() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( @@ -1498,7 +1446,7 @@ fn nursery_unstable() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1533,7 +1481,7 @@ import * as something from "../something"; let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1577,7 +1525,7 @@ fn applies_organize_imports_bug_4552() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1605,7 +1553,7 @@ import * as something from "../something"; let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1638,7 +1586,7 @@ import * as something from "../something"; let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1673,15 +1621,7 @@ import * as something from "../something"; let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--write", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--write", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1722,7 +1662,7 @@ import * as something from "../something"; "--formatter-enabled=false", "--linter-enabled=false", "--assist-enabled=true", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -1764,7 +1704,7 @@ fn ignore_configured_globals() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1815,14 +1755,7 @@ file2.js let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", file_path1.as_str(), file_path2.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1874,8 +1807,8 @@ ignored/** "--vcs-root=.", "--write", "--unsafe", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -1937,9 +1870,9 @@ fn ignore_vcs_os_independent_parse() { Args::from( [ "check", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), + file_path3.as_str(), ] .as_slice(), ), @@ -1992,8 +1925,8 @@ file2.js "--vcs-client-kind=git", "--vcs-use-ignore-file=true", "--vcs-root=.", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -2272,7 +2205,7 @@ fn should_apply_correct_file_source() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2335,7 +2268,7 @@ fn should_not_enable_all_recommended_rules() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2384,7 +2317,7 @@ array.map((sentence) => sentence.split(" ")).flat(); let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2412,15 +2345,7 @@ fn apply_bogus_argument() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - file_path.as_os_str().to_str().unwrap(), - "--write", - "--unsafe", - ] - .as_slice(), - ), + Args::from(["check", file_path.as_str(), "--write", "--unsafe"].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2451,8 +2376,8 @@ fn ignores_unknown_file() { Args::from( [ "check", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), "--files-ignore-unknown=true", ] .as_slice(), @@ -2497,7 +2422,7 @@ fn check_json_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path1.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path1.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2568,15 +2493,7 @@ A = 0; let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--write", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--write", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2631,7 +2548,7 @@ A = 0; "--write", "--unsafe", "--error-on-warnings", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -2664,15 +2581,7 @@ fn use_literal_keys_should_emit_correct_ast_issue_266() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--write", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--write", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2721,7 +2630,7 @@ fn should_show_formatter_diagnostics_for_files_ignored_by_linter() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2752,7 +2661,7 @@ fn print_json() { "--write", "--unsafe", "--reporter=json", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -2786,7 +2695,7 @@ fn print_json_pretty() { "--write", "--unsafe", "--reporter=json-pretty", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -2833,7 +2742,7 @@ fn fix_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--fix", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--fix", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2862,15 +2771,7 @@ fn fix_unsafe_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--fix", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--fix", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2902,7 +2803,7 @@ fn fix_noop() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--fix", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--fix", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2925,15 +2826,7 @@ fn fix_suggested_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--fix", - "--write", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--fix", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( @@ -2969,16 +2862,7 @@ function f() {\n\targuments;\n} let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--fix", - "--unsafe", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--fix", "--unsafe", test1.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3003,7 +2887,7 @@ fn write_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3032,15 +2916,7 @@ fn write_unsafe_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--write", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--write", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3072,7 +2948,7 @@ fn write_noop() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3095,15 +2971,7 @@ fn write_suggested_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "check", - "--write", - "--write", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["check", "--write", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( @@ -3144,8 +3012,8 @@ function f() {\n\targuments;\n} "check", "--write", "--unsafe", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), + test1.as_str(), + test2.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/commands/ci.rs b/crates/biome_cli/tests/commands/ci.rs index ffc3ef4e231e..806efa85e696 100644 --- a/crates/biome_cli/tests/commands/ci.rs +++ b/crates/biome_cli/tests/commands/ci.rs @@ -59,7 +59,7 @@ fn ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -90,7 +90,7 @@ fn formatting_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -115,7 +115,7 @@ fn ci_parse_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -139,7 +139,7 @@ fn ci_lint_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -170,7 +170,7 @@ fn ci_does_not_run_formatter() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", input_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", input_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -203,7 +203,7 @@ fn ci_does_not_run_formatter_biome_jsonc() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", input_file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", input_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -230,14 +230,7 @@ fn ci_does_not_run_formatter_via_cli() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - "--formatter-enabled=false", - input_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", "--formatter-enabled=false", input_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -269,7 +262,7 @@ fn ci_does_not_run_linter() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -296,14 +289,7 @@ fn ci_does_not_run_linter_via_cli() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - "--linter-enabled=false", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", "--linter-enabled=false", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -334,14 +320,7 @@ import * as something from "../something"; let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - "--assist-enabled=false", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", "--assist-enabled=false", file_path.as_str()].as_slice()), ); // assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -377,7 +356,7 @@ fn ci_errors_for_all_disabled_checks() { "--linter-enabled=false", "--formatter-enabled=false", "--assist-enabled=false", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -407,7 +386,7 @@ fn file_too_large() { let (mut fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -437,7 +416,7 @@ fn file_too_large_config_limit() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -462,14 +441,7 @@ fn file_too_large_cli_limit() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - "--files-max-size=16", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", "--files-max-size=16", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -494,14 +466,7 @@ fn files_max_size_parse_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - "--files-max-size=-1", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", "--files-max-size=-1", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -529,7 +494,7 @@ fn ci_runs_linter_not_formatter_issue_3495() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -661,7 +626,7 @@ fn print_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", "--verbose", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -717,7 +682,7 @@ something( ) let (fs, result) = run_cli( fs, &mut console, - Args::from(["ci", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["ci", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -770,14 +735,7 @@ file2.js let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", file_path1.as_str(), file_path2.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -826,8 +784,8 @@ file2.js "--vcs-client-kind=git", "--vcs-use-ignore-file=true", "--vcs-root=.", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -861,8 +819,8 @@ fn ignores_unknown_file() { Args::from( [ "ci", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), "--files-ignore-unknown=true", ] .as_slice(), @@ -914,9 +872,9 @@ fn correctly_handles_ignored_and_not_ignored_files() { Args::from( [ "ci", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), + file_path3.as_str(), ] .as_slice(), ), @@ -989,14 +947,7 @@ A = 0; let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "ci", - "--error-on-warnings", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["ci", "--error-on-warnings", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/commands/format.rs b/crates/biome_cli/tests/commands/format.rs index dd9b6b2682f6..b827fbad7963 100644 --- a/crates/biome_cli/tests/commands/format.rs +++ b/crates/biome_cli/tests/commands/format.rs @@ -233,7 +233,7 @@ fn print() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -260,7 +260,7 @@ fn write() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -289,7 +289,7 @@ fn format_shows_parse_diagnostics() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -350,7 +350,7 @@ fn lint_warning() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -400,7 +400,7 @@ fn custom_config_file_path() { "format", format!("--config-path={}", config_path.to_string().as_str()).as_str(), "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -440,7 +440,7 @@ fn invalid_config_file_path() { "--config-path", (config_path.to_string().as_str()), "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -478,7 +478,7 @@ fn applies_custom_configuration() { "--indent-width", "8", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -521,7 +521,7 @@ fn applies_custom_configuration_over_config_file() { "--indent-width", "8", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -554,15 +554,7 @@ fn applies_custom_configuration_over_config_file_issue_3175_v1() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--quote-style", - "single", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--quote-style", "single", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -597,15 +589,7 @@ fn applies_custom_configuration_over_config_file_issue_3175_v2() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--indent-style", - "space", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--indent-style", "space", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -640,7 +624,7 @@ fn applies_custom_jsx_quote_style() { "--quote-properties", "preserve", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -678,7 +662,7 @@ fn applies_custom_quote_style() { "--quote-properties", "preserve", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -718,7 +702,7 @@ fn applies_custom_css_quote_style() { "--css-formatter-quote-style", "single", "--write", - css_file_path.as_os_str().to_str().unwrap(), + css_file_path.as_str(), ] .as_slice(), ), @@ -754,7 +738,7 @@ fn applies_custom_trailing_commas() { "--trailing-commas", "none", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -790,7 +774,7 @@ fn applies_custom_attribute_position() { "--attribute-position", "multiline", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -826,7 +810,7 @@ fn applies_custom_arrow_parentheses() { "--arrow-parentheses", "as-needed", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -862,7 +846,7 @@ fn applies_custom_bracket_spacing() { "--bracket-spacing", "false", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -898,7 +882,7 @@ fn applies_custom_bracket_same_line() { "--bracket-same-line", "true", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -955,7 +939,7 @@ fn with_semicolons_options() { "format", "--semicolons=as-needed", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -1336,8 +1320,8 @@ fn does_not_format_if_files_are_listed_in_ignore_option() { Args::from( [ "format", - file_path_test1.as_os_str().to_str().unwrap(), - file_path_test2.as_os_str().to_str().unwrap(), + file_path_test1.as_str(), + file_path_test2.as_str(), "--write", ] .as_slice(), @@ -1537,7 +1521,7 @@ fn fs_error_read_only() { let (mut fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1565,7 +1549,7 @@ fn file_too_large() { let (mut fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap(), "--write"].as_slice()), + Args::from(["format", file_path.as_str(), "--write"].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1595,7 +1579,7 @@ fn file_too_large_config_limit() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1620,14 +1604,7 @@ fn file_too_large_cli_limit() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--files-max-size=16", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--files-max-size=16", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1652,14 +1629,7 @@ fn files_max_size_parse_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--files-max-size=-1", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--files-max-size=-1", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1804,14 +1774,7 @@ fn print_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--verbose", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1872,8 +1835,8 @@ file2.js [ "format", "--write", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -1933,8 +1896,8 @@ file2.js "--vcs-use-ignore-file=true", "--vcs-root=.", "--write", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -2080,8 +2043,8 @@ fn ignores_unknown_file() { Args::from( [ "format", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), "--files-ignore-unknown=true", ] .as_slice(), @@ -2142,7 +2105,7 @@ fn ignore_comments_error_when_allow_comments() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2172,7 +2135,7 @@ fn format_jsonc_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2209,7 +2172,7 @@ fn format_json_when_allow_trailing_commas() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2243,7 +2206,7 @@ fn format_json_when_allow_trailing_commas_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2280,7 +2243,7 @@ fn format_json_trailing_commas_none() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2317,7 +2280,7 @@ fn format_json_trailing_commas_all() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2360,7 +2323,7 @@ fn format_json_trailing_commas_overrides_all() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2403,7 +2366,7 @@ fn format_json_trailing_commas_overrides_none() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2439,15 +2402,7 @@ fn treat_known_json_files_as_jsonc_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - eslint.as_os_str().to_str().unwrap(), - jshint.as_os_str().to_str().unwrap(), - babel.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", eslint.as_str(), jshint.as_str(), babel.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2520,9 +2475,9 @@ const a = { [ "format", "--write", - json_file.as_os_str().to_str().unwrap(), - js_file.as_os_str().to_str().unwrap(), - css_file.as_os_str().to_str().unwrap(), + json_file.as_str(), + js_file.as_str(), + css_file.as_str(), ] .as_slice(), ), @@ -2588,9 +2543,9 @@ const a = { "--css-formatter-line-width=40", "--css-formatter-indent-width=6", "--css-formatter-enabled=true", - json_file.as_os_str().to_str().unwrap(), - js_file.as_os_str().to_str().unwrap(), - css_file.as_os_str().to_str().unwrap(), + json_file.as_str(), + js_file.as_str(), + css_file.as_str(), ] .as_slice(), ), @@ -2652,15 +2607,7 @@ const a = { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - json_file.as_os_str().to_str().unwrap(), - js_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", json_file.as_str(), js_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2721,15 +2668,7 @@ const a = { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - json_file.as_os_str().to_str().unwrap(), - js_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", json_file.as_str(), js_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2789,15 +2728,7 @@ const a = { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - css_file.as_os_str().to_str().unwrap(), - js_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", css_file.as_str(), js_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2861,15 +2792,7 @@ const a = { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - json_file.as_os_str().to_str().unwrap(), - js_file.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", json_file.as_str(), js_file.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3045,7 +2968,7 @@ fn applies_configuration_from_biome_jsonc() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3092,7 +3015,7 @@ fn format_package_json() { "format", "--write", "--indent-style=space", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3127,7 +3050,7 @@ fn format_svelte_implicit_js_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", svelte_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -3157,14 +3080,7 @@ fn format_svelte_implicit_js_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - svelte_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3194,7 +3110,7 @@ fn format_svelte_explicit_js_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", svelte_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -3224,14 +3140,7 @@ fn format_svelte_explicit_js_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - svelte_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3258,14 +3167,7 @@ fn format_empty_svelte_js_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - svelte_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3295,7 +3197,7 @@ fn format_svelte_ts_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", svelte_file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -3325,14 +3227,7 @@ fn format_svelte_ts_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - svelte_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3359,14 +3254,7 @@ fn format_empty_svelte_ts_files_write() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--write", - svelte_file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--write", svelte_file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3417,7 +3305,7 @@ fn should_format_files_in_folders_ignored_by_linter() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3442,14 +3330,7 @@ fn print_json() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--reporter=json", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--reporter=json", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -3476,14 +3357,7 @@ fn print_json_pretty() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "format", - "--reporter=json-pretty", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["format", "--reporter=json-pretty", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -3531,7 +3405,7 @@ fn fix() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--fix", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["format", "--fix", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3615,7 +3489,7 @@ fn applies_custom_bracket_spacing_for_graphql() { "--bracket-spacing", "false", "--write", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs index 61cd381c258f..6cce3c48ff7a 100644 --- a/crates/biome_cli/tests/commands/lint.rs +++ b/crates/biome_cli/tests/commands/lint.rs @@ -81,7 +81,7 @@ fn ok() { let (_, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -98,7 +98,7 @@ fn ok_read_only() { let (_, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -115,7 +115,7 @@ fn parse_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -138,7 +138,7 @@ fn maximum_diagnostics() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -183,7 +183,7 @@ fn apply_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -216,7 +216,7 @@ fn apply_noop() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -241,15 +241,7 @@ fn apply_suggested_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -274,15 +266,7 @@ fn apply_suggested() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--write", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--write", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -335,8 +319,8 @@ function f() { arguments; } "lint", "--write", "--unsafe", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), + test1.as_str(), + test2.as_str(), ] .as_slice(), ), @@ -370,7 +354,7 @@ fn no_lint_if_linter_is_disabled_when_run_apply() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -406,7 +390,7 @@ fn no_lint_if_linter_is_disabled_when_run_apply_biome_jsonc() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -442,7 +426,7 @@ fn no_lint_if_linter_is_disabled() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -478,7 +462,7 @@ fn should_disable_a_rule() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -517,7 +501,7 @@ fn should_disable_a_rule_group() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -555,7 +539,7 @@ fn downgrade_severity() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); println!("{console:?}"); @@ -601,14 +585,7 @@ fn downgrade_severity_info() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--error-on-warnings", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--error-on-warnings", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -652,7 +629,7 @@ fn upgrade_severity() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -697,7 +674,7 @@ fn no_lint_when_file_is_ignored() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -740,8 +717,8 @@ fn no_lint_if_files_are_listed_in_ignore_option() { [ "lint", "--write", - file_path_test1.as_os_str().to_str().unwrap(), - file_path_test2.as_os_str().to_str().unwrap(), + file_path_test1.as_str(), + file_path_test2.as_str(), ] .as_slice(), ), @@ -950,7 +927,7 @@ fn fs_error_read_only() { let (mut fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1290,7 +1267,7 @@ fn file_too_large() { let (mut fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1320,7 +1297,7 @@ fn file_too_large_config_limit() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1345,14 +1322,7 @@ fn file_too_large_cli_limit() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--files-max-size=16", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--files-max-size=16", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1377,14 +1347,7 @@ fn files_max_size_parse_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--files-max-size=-1", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--files-max-size=-1", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1455,7 +1418,7 @@ fn max_diagnostics() { "lint", "--max-diagnostics", "10", - Utf8Path::new("src").as_os_str().to_str().unwrap(), + Utf8Path::new("src").as_str(), ] .as_slice(), ), @@ -1515,7 +1478,7 @@ fn print_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--verbose", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1540,7 +1503,7 @@ fn unsupported_file() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1564,7 +1527,7 @@ fn unsupported_file_verbose() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--verbose", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--verbose", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1588,7 +1551,7 @@ fn suppression_syntax_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1616,7 +1579,7 @@ fn config_recommended_group() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( @@ -1639,7 +1602,7 @@ fn nursery_unstable() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1685,7 +1648,7 @@ fn group_level_recommended_false_enable_specific() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1729,7 +1692,7 @@ fn ignore_configured_globals() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1780,14 +1743,7 @@ file2.js let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", file_path1.as_str(), file_path2.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1843,9 +1799,9 @@ fn ignore_vcs_os_independent_parse() { Args::from( [ "lint", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), + file_path3.as_str(), ] .as_slice(), ), @@ -1898,8 +1854,8 @@ file2.js "--vcs-client-kind=git", "--vcs-use-ignore-file=true", "--vcs-root=.", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -2064,7 +2020,7 @@ fn should_apply_correct_file_source() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2127,7 +2083,7 @@ fn should_not_enable_all_recommended_rules() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2176,7 +2132,7 @@ array.map((sentence) => sentence.split(" ")).flat(); let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2204,15 +2160,7 @@ fn apply_bogus_argument() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - file_path.as_os_str().to_str().unwrap(), - "--write", - "--unsafe", - ] - .as_slice(), - ), + Args::from(["lint", file_path.as_str(), "--write", "--unsafe"].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2243,8 +2191,8 @@ fn ignores_unknown_file() { Args::from( [ "lint", - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path1.as_str(), + file_path2.as_str(), "--files-ignore-unknown=true", ] .as_slice(), @@ -2289,7 +2237,7 @@ fn check_json_files() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path1.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path1.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2415,7 +2363,7 @@ A = 0; "--write", "--unsafe", "--error-on-warnings", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -2453,8 +2401,8 @@ fn should_only_processes_changed_files_when_changed_flag_is_set() { "lint", "--changed", "--since=main", - file_path.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -2487,15 +2435,7 @@ fn should_error_if_changed_flag_is_used_without_since_or_default_branch_config() let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--changed", - file_path.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--changed", file_path.as_str(), file_path2.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2538,15 +2478,7 @@ fn should_process_changed_files_if_changed_flag_is_set_and_default_branch_is_con let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--changed", - file_path.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--changed", file_path.as_str(), file_path2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2580,8 +2512,8 @@ fn should_error_if_since_arg_is_used_without_changed() { [ "lint", "--since=main", - file_path.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -2637,8 +2569,8 @@ fn should_only_process_changed_file_if_its_included() { "lint", "--changed", "--since=main", - file_path.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -2692,8 +2624,8 @@ fn should_not_process_ignored_file_even_if_its_changed() { "lint", "--changed", "--since=main", - file_path.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -2730,8 +2662,8 @@ fn should_not_error_for_no_changed_files_with_no_errors_on_unmatched() { "--changed", "--since=main", "--no-errors-on-unmatched", - file_path.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), + file_path.as_str(), + file_path2.as_str(), ] .as_slice(), ), @@ -2924,7 +2856,7 @@ fn lint_syntax_rules() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2970,7 +2902,7 @@ fn lint_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2995,14 +2927,7 @@ fn lint_only_rule_doesnt_exist() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--only=suspicious/inexistant", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--only=suspicious/inexistant", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -3027,14 +2952,7 @@ fn lint_only_missing_group() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--only=noDebugger", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--only=noDebugger", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -3060,14 +2978,7 @@ fn lint_only_rule() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--only=suspicious/noDebugger", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--only=suspicious/noDebugger", file_path.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -3096,7 +3007,7 @@ fn lint_only_multiple_rules() { "lint", "--only=suspicious/noDebugger", "--only=performance/noDelete", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3128,7 +3039,7 @@ fn lint_only_rule_and_group() { "lint", "--only=suspicious/noDebugger", "--only=performance", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3159,14 +3070,7 @@ fn lint_only_rule_ignore_suppression_comments() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--only=suspicious/noDebugger", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--only=suspicious/noDebugger", file_path.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -3213,7 +3117,7 @@ fn lint_only_rule_with_config() { [ "lint", "--only=style/useNamingConvention", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3255,7 +3159,7 @@ fn lint_only_rule_with_recommended_disabled() { [ "lint", "--only=lint/style/useNamingConvention", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3295,7 +3199,7 @@ fn lint_only_rule_with_linter_disabled() { [ "lint", "--only=style/useNamingConvention", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3337,14 +3241,7 @@ fn lint_only_group() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--only=suspicious", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--only=suspicious", file_path.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -3383,14 +3280,7 @@ fn lint_only_group_with_disabled_rule() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--only=lint/suspicious", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--only=lint/suspicious", file_path.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -3427,7 +3317,7 @@ fn lint_only_write() { "lint", "--write", "--only=complexity/useArrowFunction", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3454,14 +3344,7 @@ fn lint_skip_rule() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--skip=suspicious/noDebugger", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--skip=suspicious/noDebugger", file_path.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -3496,14 +3379,7 @@ fn lint_skip_group_with_enabled_rule() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--skip=suspicious", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--skip=suspicious", file_path.as_str()].as_slice()), ); assert_cli_snapshot(SnapshotPayload::new( @@ -3532,7 +3408,7 @@ fn lint_skip_multiple_rules() { "lint", "--skip=suspicious/noDebugger", "--skip=performance/noDelete", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3564,7 +3440,7 @@ fn lint_skip_rule_and_group() { "lint", "--skip=suspicious/noDebugger", "--skip=performance", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3604,7 +3480,7 @@ fn lint_skip_write() { "lint", "--write", "--skip=complexity/useArrowFunction", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3636,7 +3512,7 @@ fn lint_only_group_skip_rule() { "lint", "--only=suspicious", "--skip=suspicious/noDebugger", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3668,7 +3544,7 @@ fn lint_only_rule_skip_group() { "lint", "--only=suspicious/noDebugger", "--skip=suspicious", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3700,7 +3576,7 @@ fn lint_only_skip_rule() { "lint", "--only=suspicious/noDebugger", "--skip=suspicious/noDebugger", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3732,7 +3608,7 @@ fn lint_only_skip_group() { "lint", "--only=suspicious", "--skip=suspicious", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -3756,7 +3632,7 @@ fn fix_ok() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--fix", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--fix", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3784,7 +3660,7 @@ fn fix_noop() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", "--fix", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", "--fix", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( @@ -3805,15 +3681,7 @@ fn fix_suggested_error() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--fix", - "--write", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--fix", "--write", file_path.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( @@ -3834,15 +3702,7 @@ fn fix_suggested() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--fix", - "--unsafe", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--fix", "--unsafe", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -3883,16 +3743,7 @@ function f() { arguments; } let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "lint", - "--fix", - "--unsafe", - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["lint", "--fix", "--unsafe", test1.as_str(), test2.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); assert_file_contents(&fs, test1, expected); @@ -3979,7 +3830,7 @@ fn linter_shows_the_default_severity_of_rule_on() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["lint", file.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["lint", file.as_str()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( diff --git a/crates/biome_cli/tests/commands/search.rs b/crates/biome_cli/tests/commands/search.rs index c782a5b96bb3..fc3fa433a1f7 100644 --- a/crates/biome_cli/tests/commands/search.rs +++ b/crates/biome_cli/tests/commands/search.rs @@ -34,7 +34,7 @@ fn search_css_pattern() { "search", "--language=css", "`color: green`", - file_path.as_os_str().to_str().unwrap(), + file_path.as_str(), ] .as_slice(), ), @@ -62,15 +62,7 @@ fn search_css_pattern_shorthand() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "search", - "-lcss", - "`color: green`", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["search", "-lcss", "`color: green`", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -95,14 +87,7 @@ fn search_js_pattern() { let (fs, result) = run_cli( fs, &mut console, - Args::from( - [ - "search", - "`\"foo\"`", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), + Args::from(["search", "`\"foo\"`", file_path.as_str()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_grit_formatting_options.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_grit_formatting_options.snap new file mode 100644 index 000000000000..2337721e0808 --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_grit_formatting_options.snap @@ -0,0 +1,78 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: content +snapshot_kind: text +--- +## `biome.json` + +```json +{ + "formatter": { + "indentStyle": "tab" + }, + "overrides": [ + { + "include": ["file.grit"], + "grit": { "formatter": { "indentStyle": "space", "indentWidth": 8 } } + } + ] +} +``` + +## `file.grit` + +```grit +`console.$_($content)` where { $content <: contains `secret` until `sanitized($_)` } +``` + +## `file.js` + +```js +function name() { return "hello"; } +``` + +# Termination Message + +```block +format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Some errors were emitted while running checks. + + + +``` + +# Emitted Messages + +```block +file.grit format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Formatter would have printed the following content: + + 1 │ - `console.$_($content)`·where·{·$content·<:·contains·`secret`·until·`sanitized($_)`·} + 1 │ + `console.$_($content)`·where·{ + 2 │ + ········$content·<:·contains·`secret`·until·`sanitized($_)` + 3 │ + } + 4 │ + + + +``` + +```block +file.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Formatter would have printed the following content: + + 1 │ - function·name()·{·return·"hello";·} + 1 │ + function·name()·{ + 2 │ + → return·"hello"; + 3 │ + } + 4 │ + + + +``` + +```block +Checked 2 files in