From 31c4a450f5a19c52abb9773a4e58bc603be0d7db Mon Sep 17 00:00:00 2001 From: unvalley Date: Mon, 20 May 2024 03:47:05 +0900 Subject: [PATCH 1/6] chore: deprecate `--apply` and `--apply-unsafe` of lint and check commands --- crates/biome_cli/src/commands/mod.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index a2494f74605d..96c598635181 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -1,6 +1,6 @@ use crate::changed::{get_changed_files, get_staged_files}; use crate::cli_options::{cli_options, CliOptions, ColorsArg}; -use crate::diagnostics::DeprecatedConfigurationFile; +use crate::diagnostics::{DeprecatedArgument, DeprecatedConfigurationFile}; use crate::execute::Stdin; use crate::logging::LoggingKind; use crate::{CliDiagnostic, CliSession, LoggingLevel, VERSION}; @@ -91,11 +91,11 @@ pub enum BiomeCommand { #[bpaf(long("fix"), switch, hide_usage)] fix: bool, - /// Alias for `--write`, writes safe fixes, formatting and import sorting + /// Alias for `--write`, writes safe fixes, formatting and import sorting (deprecated, use `--write`) #[bpaf(long("apply"), switch, hide_usage)] apply: bool, - /// Alias for `--write --unsafe`, writes safe and unsafe fixes, formatting and import sorting + /// Alias for `--write --unsafe`, writes safe and unsafe fixes, formatting and import sorting (deprecated, use `--write --unsafe`) #[bpaf(long("apply-unsafe"), switch, hide_usage)] apply_unsafe: bool, @@ -164,11 +164,11 @@ pub enum BiomeCommand { #[bpaf(long("fix"), switch, hide_usage)] fix: bool, - /// Alias for `--write`, writes safe fixes + /// Alias for `--write`, writes safe fixes (deprecated, use `--write`) #[bpaf(long("apply"), switch, hide_usage)] apply: bool, - /// Alias for `--write --unsafe`, writes safe and unsafe fixes + /// Alias for `--write --unsafe`, writes safe and unsafe fixes (deprecated, use `--write --unsafe`) #[bpaf(long("apply-unsafe"), switch, hide_usage)] apply_unsafe: bool, @@ -640,7 +640,7 @@ pub(crate) struct FixFileModeOptions { /// - [FixFileMode]: if safe or unsafe fixes are requested pub(crate) fn determine_fix_file_mode( options: FixFileModeOptions, - _console: &mut dyn Console, + console: &mut dyn Console, ) -> Result, CliDiagnostic> { let FixFileModeOptions { apply, @@ -650,6 +650,18 @@ pub(crate) fn determine_fix_file_mode( unsafe_, } = options; + if apply || apply_unsafe { + let (deprecated, alternative) = if apply { + ("--apply", "--write") + } else { + ("--apply-unsafe", "--write --unsafe") + }; + let diagnostic = DeprecatedArgument::new(markup! { + "The argument "{deprecated}" is deprecated, it will be removed in the next major release. Use "{alternative}" instead." + }); + console.error(markup! {{PrintDiagnostic::simple(&diagnostic)}}); + } + check_fix_incompatible_arguments(options)?; let safe_fixes = apply || write || fix; From 0f65a9cec6a338fc148dbdac1c1b5fdf119fc86f Mon Sep 17 00:00:00 2001 From: unvalley Date: Mon, 20 May 2024 03:47:16 +0900 Subject: [PATCH 2/6] CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6f4f28164fa..24f04c0a178f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b The `biome migrate --fix` has the same behavior as `biome migrate --write`. This change allows these commands to write modifications in the same options. + With this change, the `--apply` and `--apply-unsafe` option is deprecated. Contributed by @unvalley From 41319fc24b2ebb3d99a5052d7df15341c07959fb Mon Sep 17 00:00:00 2001 From: unvalley Date: Mon, 20 May 2024 03:50:39 +0900 Subject: [PATCH 3/6] Update snapshot tests --- .../check_biome_json.snap | 8 ++++++++ .../linter_biome_json.snap | 8 ++++++++ .../lint_and_fix_astro_files.snap | 8 ++++++++ .../sorts_imports_write.snap | 8 ++++++++ .../sorts_imports_write.snap | 8 ++++++++ .../sorts_imports_write.snap | 8 ++++++++ ..._included_files_if_overridden_by_ignore_linter.snap | 8 ++++++++ ...cluded_files_if_overridden_by_organize_imports.snap | 8 ++++++++ .../does_handle_included_file_and_disable_linter.snap | 8 ++++++++ ...with_different_linting_and_applies_all_of_them.snap | 8 ++++++++ .../does_include_file_with_different_overrides.snap | 8 ++++++++ .../does_include_file_with_different_rules.snap | 8 ++++++++ .../does_merge_all_overrides.snap | 8 ++++++++ .../does_not_change_linting_settings.snap | 8 ++++++++ .../does_override_groupe_recommended.snap | 8 ++++++++ .../does_override_recommended.snap | 8 ++++++++ .../does_override_the_rules.snap | 8 ++++++++ ...up_recommended_when_override_global_recommened.snap | 8 ++++++++ ...eserve_individually_diabled_rules_in_overrides.snap | 8 ++++++++ ...dle_included_file_and_disable_organize_imports.snap | 8 ++++++++ .../main_commands_check/applies_organize_imports.snap | 8 ++++++++ .../applies_organize_imports_from_cli.snap | 8 ++++++++ .../main_commands_check/apply_bogus_argument.snap | 8 ++++++++ .../snapshots/main_commands_check/apply_noop.snap | 8 ++++++++ .../tests/snapshots/main_commands_check/apply_ok.snap | 8 ++++++++ .../snapshots/main_commands_check/apply_suggested.snap | 8 ++++++++ .../main_commands_check/apply_suggested_error.snap | 8 ++++++++ .../main_commands_check/apply_unsafe_with_error.snap | 8 ++++++++ .../snapshots/main_commands_check/check_help.snap | 5 +++-- .../does_error_with_only_warnings.snap | 8 ++++++++ ...dont_applies_organize_imports_for_ignored_file.snap | 8 ++++++++ .../main_commands_check/fix_suggested_error.snap | 10 ++++++++++ .../main_commands_check/fs_error_read_only.snap | 8 ++++++++ .../main_commands_check/fs_files_ignore_symlink.snap | 8 ++++++++ .../ignores_file_inside_directory.snap | 8 ++++++++ .../no_lint_if_files_are_listed_in_ignore_option.snap | 8 ++++++++ .../no_lint_if_linter_is_disabled_when_run_apply.snap | 8 ++++++++ ..._linter_is_disabled_when_run_apply_biome_jsonc.snap | 8 ++++++++ .../no_lint_when_file_is_ignored.snap | 8 ++++++++ .../snapshots/main_commands_check/print_json.snap | 8 ++++++++ .../main_commands_check/print_json_pretty.snap | 8 ++++++++ .../main_commands_check/should_disable_a_rule.snap | 8 ++++++++ .../should_disable_a_rule_group.snap | 8 ++++++++ .../should_organize_imports_diff_on_check.snap | 8 ++++++++ .../should_pass_if_there_are_only_warnings.snap | 8 ++++++++ ...literal_keys_should_emit_correct_ast_issue_266.snap | 8 ++++++++ .../main_commands_check/write_suggested_error.snap | 10 ++++++++++ .../main_commands_lint/apply_bogus_argument.snap | 8 ++++++++ .../tests/snapshots/main_commands_lint/apply_noop.snap | 8 ++++++++ .../tests/snapshots/main_commands_lint/apply_ok.snap | 8 ++++++++ .../snapshots/main_commands_lint/apply_suggested.snap | 8 ++++++++ .../main_commands_lint/apply_suggested_error.snap | 8 ++++++++ .../main_commands_lint/apply_unsafe_with_error.snap | 8 ++++++++ .../does_error_with_only_warnings.snap | 8 ++++++++ .../main_commands_lint/fs_error_read_only.snap | 8 ++++++++ .../tests/snapshots/main_commands_lint/lint_help.snap | 5 +++-- .../no_lint_if_files_are_listed_in_ignore_option.snap | 8 ++++++++ .../no_lint_if_linter_is_disabled_when_run_apply.snap | 8 ++++++++ ..._linter_is_disabled_when_run_apply_biome_jsonc.snap | 8 ++++++++ .../no_lint_when_file_is_ignored.snap | 8 ++++++++ .../main_commands_lint/should_disable_a_rule.snap | 8 ++++++++ .../should_disable_a_rule_group.snap | 8 ++++++++ .../should_pass_if_there_are_only_warnings.snap | 8 ++++++++ 63 files changed, 498 insertions(+), 4 deletions(-) diff --git a/crates/biome_cli/tests/snapshots/main_cases_biome_json_support/check_biome_json.snap b/crates/biome_cli/tests/snapshots/main_cases_biome_json_support/check_biome_json.snap index 02f41fb8870c..3d460868d68a 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_biome_json_support/check_biome_json.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_biome_json_support/check_biome_json.snap @@ -26,6 +26,14 @@ debugger; # Emitted Messages +```block +internalError/fs DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! The argument --apply is deprecated, it will be removed in the next major release. Use --write instead. + + +``` + ```block Checked 1 file in