diff --git a/.changeset/reduced_accepted_values.md b/.changeset/reduced_accepted_values.md new file mode 100644 index 000000000000..5943c3c434b8 --- /dev/null +++ b/.changeset/reduced_accepted_values.md @@ -0,0 +1,12 @@ +--- +cli: major +--- + +# Reduced accepted values for formatter options + +- The option `--quote-style` doesn't accept `Single` and `Double` anymore. +- The option `--quote-properties` doesn't accept `AsNeeded` and `Preserve` anymore. +- The option `--semicolons` doesn't accept `AsNeeded` and `Always` anymore. +- The option `--arrow-parenthesis` doesn't accept `AsNeeded` and `Always` anymore. +- The option `--trailing-commas` doesn't accept `ES5`, `All` and `None` anymore. +- The option `--attribute-position` doesn't accept `Single` and `Multiline` anymore. diff --git a/.changeset/reduced_accepted_values_for_js_options.md b/.changeset/reduced_accepted_values_for_js_options.md new file mode 100644 index 000000000000..536548d026f5 --- /dev/null +++ b/.changeset/reduced_accepted_values_for_js_options.md @@ -0,0 +1,9 @@ +--- +biome_js_formatter: major +--- + +# Reduced accepted values for js options + +- The type `Semicolon` can't be converted from `"AsNeeded"` and `"Always"`. +- The type `TrailingCommas` can't be converted from `"ES5"`, `"All"` and `"None"`. +- The type `ArrowParenthesis` can't be converted from `"AsNeeded"` and `"Always"`. diff --git a/.changeset/reduced_accepted_values_of_options.md b/.changeset/reduced_accepted_values_of_options.md new file mode 100644 index 000000000000..05c3b35adf5d --- /dev/null +++ b/.changeset/reduced_accepted_values_of_options.md @@ -0,0 +1,9 @@ +--- +biome_formatter: major +--- + +# Reduced accepted values of options + +- The type `QuoteStyle` can't be converted from `"Double"` and `"Single"`. +- The type `QuoteProperties` can't be converted from `"AsNeeded"` and `"Preserve"`. +- The type `AttributePosition` can't be converted from `"Multiline"` and `"Auto"`. diff --git a/.changeset/remove_biome_log_dir.md b/.changeset/remove_biome_log_dir.md new file mode 100644 index 000000000000..c91762ff663f --- /dev/null +++ b/.changeset/remove_biome_log_dir.md @@ -0,0 +1,9 @@ +--- +cli: major +--- + +# Remove `BIOME_LOG_DIR` + +The environment variable `BIOME_LOG_DIR` isn't supported anymore. + +Use `BIOME_LOG_PATH` instead. diff --git a/.changeset/remove_indentsize_option.md b/.changeset/remove_indentsize_option.md new file mode 100644 index 000000000000..910a9d090c7f --- /dev/null +++ b/.changeset/remove_indentsize_option.md @@ -0,0 +1,15 @@ +--- +cli: major +--- + +# Remove `indentSize` deprecated option + +The deprecated option `indentSize`, and its relative CLI options, has been removed: +- Configuration file: `formatter.indentSize` +- Configuration file: `javascript.formatter.indentSize` +- Configuration file: `json.formatter.indentSize` +- CLI option `--indent-size` +- CLI option `--javascript-formatter-indent-size` +- CLI option `--json-formatter-indent-size` + +Use `indentWidth` and its relative CLI options instead. diff --git a/.changeset/remove_support_for_rome_ignore_suppression_comment.md b/.changeset/remove_support_for_rome_ignore_suppression_comment.md new file mode 100644 index 000000000000..f53a096cadb9 --- /dev/null +++ b/.changeset/remove_support_for_rome_ignore_suppression_comment.md @@ -0,0 +1,7 @@ +--- +cli: major +--- + +# Remove support for `rome-ignore` suppression comment + +Use the `biome-ignore` suppression comment instead. diff --git a/.changeset/remove_support_for_romejson.md b/.changeset/remove_support_for_romejson.md new file mode 100644 index 000000000000..dcd88227a414 --- /dev/null +++ b/.changeset/remove_support_for_romejson.md @@ -0,0 +1,5 @@ +--- +cli: major +--- + +# Remove support for `rome.json` diff --git a/.changeset/remove_trailingcomma.md b/.changeset/remove_trailingcomma.md new file mode 100644 index 000000000000..05040222d331 --- /dev/null +++ b/.changeset/remove_trailingcomma.md @@ -0,0 +1,23 @@ +--- +cli: major +--- + +# Remove `trailingComma` + +Removed the option `trailingComma` from the configuration and the CLI. Use the option `trailingCommas` instead: + +```diff +{ + "javascript": { + "formatter": { +- "trailingComma": "es5" ++ "trailingCommas": "es5" + } + } +} +``` + +```diff +-biome format --trailing-comma=es5 ++biome format --trailing-commas=es5 +``` diff --git a/.changeset/removed_apply_and_apply_unsafe.md b/.changeset/removed_apply_and_apply_unsafe.md new file mode 100644 index 000000000000..f3cb7b6b2ae3 --- /dev/null +++ b/.changeset/removed_apply_and_apply_unsafe.md @@ -0,0 +1,17 @@ +--- +cli: major +--- + +# Removed `--apply` and `--apply-unsafe` + +The CLI options `--apply` and `--apply-unasfe` aren't accepted anymore. Use `--write` and `--write --unafe` instead: + +```diff +-biome check --apply-unsafe ++biome check --write --unsafe +``` + +```diff +-biome check --apply ++biome check --write +``` diff --git a/.changeset/the_rule_useexhaustivedependencies_isnt_recommended_anymore.md b/.changeset/the_rule_useexhaustivedependencies_isnt_recommended_anymore.md new file mode 100644 index 000000000000..0865230938d5 --- /dev/null +++ b/.changeset/the_rule_useexhaustivedependencies_isnt_recommended_anymore.md @@ -0,0 +1,21 @@ +--- +cli: major +--- + +# The rule `useExhaustiveDependencies` isn't recommended anymore + +The rule `useExhaustiveDependencies` is not recommended anymore. If your codebase uses `react` and relies on that rule, you have to enable it: + + +```jsonc +// biome.json +{ + "linter": { + "rules": { + "correctness": { + "useExhaustiveDependencies": "error" + } + } + } +} +``` diff --git a/Cargo.lock b/Cargo.lock index f71699e99604..85bac7a2f284 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1156,6 +1156,7 @@ dependencies = [ "biome_console", "biome_diagnostics", "biome_rowan", + "log", ] [[package]] @@ -1207,7 +1208,7 @@ version = "0.5.7" [[package]] name = "biome_wasm" -version = "1.7.3" +version = "1.9.3" dependencies = [ "biome_console", "biome_diagnostics", diff --git a/crates/biome_analyze/src/lib.rs b/crates/biome_analyze/src/lib.rs index e20f13b34f1f..69f48c157168 100644 --- a/crates/biome_analyze/src/lib.rs +++ b/crates/biome_analyze/src/lib.rs @@ -45,16 +45,13 @@ pub use crate::signals::{ }; pub use crate::syntax::{Ast, SyntaxVisitor}; pub use crate::visitor::{NodeVisitor, Visitor, VisitorContext, VisitorFinishContext}; -pub use suppression_action::{ApplySuppression, SuppressionAction}; - use biome_console::markup; -use biome_diagnostics::{ - category, Applicability, Diagnostic, DiagnosticExt, DiagnosticTags, Severity, -}; +use biome_diagnostics::{category, Applicability, Diagnostic, DiagnosticExt, DiagnosticTags}; use biome_rowan::{ - AstNode, BatchMutation, Direction, Language, SyntaxElement, SyntaxToken, TextLen, TextRange, - TextSize, TokenAtOffset, TriviaPiece, TriviaPieceKind, WalkEvent, + AstNode, BatchMutation, Direction, Language, SyntaxElement, SyntaxToken, TextRange, TextSize, + TokenAtOffset, TriviaPieceKind, WalkEvent, }; +pub use suppression_action::{ApplySuppression, SuppressionAction}; /// The analyzer is the main entry point into the `biome_analyze` infrastructure. /// Its role is to run a collection of [Visitor]s over a syntax tree, with each @@ -474,27 +471,11 @@ where } }; - if matches!(kind, SuppressionKind::Deprecated) { - let signal = DiagnosticSignal::new(move || { - SuppressionDiagnostic::new( - category!("suppressions/deprecatedSuppressionComment"), - range, - "// rome-ignore is deprecated, use // biome-ignore instead", - ) - .with_tags(DiagnosticTags::DEPRECATED_CODE) - .with_severity(Severity::Information) - }) - .with_action(move || create_suppression_comment_action(token)); - - (self.emit_signal)(&signal)?; - } - let (rule, instance) = match kind { SuppressionKind::Everything => (None, None), SuppressionKind::Rule(rule) => (Some(rule), None), SuppressionKind::RuleInstance(rule, instance) => (Some(rule), Some(instance)), SuppressionKind::MaybeLegacy(rule) => (Some(rule), None), - SuppressionKind::Deprecated => (None, None), }; if let Some(rule) = rule { @@ -637,55 +618,6 @@ where } } -fn create_suppression_comment_action( - token: &SyntaxToken, -) -> Option> { - let first_node = token.parent()?; - let mut new_leading_trivia = vec![]; - let mut token_text = String::new(); - let mut new_trailing_trivia = vec![]; - let mut mutation = BatchMutation::new(first_node); - - for piece in token.leading_trivia().pieces() { - if !piece.is_comments() { - new_leading_trivia.push(TriviaPiece::new(piece.kind(), piece.text_len())); - token_text.push_str(piece.text()); - } - - if piece.text().contains("rome-ignore") { - let new_text = piece.text().replace("rome-ignore", "biome-ignore"); - new_leading_trivia.push(TriviaPiece::new(piece.kind(), new_text.text_len())); - token_text.push_str(&new_text); - } - } - - token_text.push_str(token.text_trimmed()); - - for piece in token.trailing_trivia().pieces() { - new_trailing_trivia.push(TriviaPiece::new(piece.kind(), piece.text_len())); - token_text.push_str(piece.text()); - } - - let new_token = SyntaxToken::new_detached( - token.kind(), - &token_text, - new_leading_trivia, - new_trailing_trivia, - ); - - mutation.replace_token_discard_trivia(token.clone(), new_token); - Some(AnalyzerAction { - mutation, - applicability: Applicability::MaybeIncorrect, - category: ActionCategory::QuickFix, - message: markup! { - "Use // biome-ignore instead" - } - .to_owned(), - rule_name: None, - }) -} - fn range_match(filter: Option, range: TextRange) -> bool { filter.map_or(true, |filter| filter.intersect(range).is_some()) } @@ -717,8 +649,6 @@ pub enum SuppressionKind<'a> { RuleInstance(&'a str, &'a str), /// A suppression using the legacy syntax to disable a specific rule eg. `// biome-ignore lint(style/useWhile)` MaybeLegacy(&'a str), - /// `rome-ignore` is legacy - Deprecated, } fn update_suppression( @@ -782,7 +712,7 @@ pub struct SuppressionCommentEmitterPayload<'a, L: Language> { pub token_offset: TokenAtOffset>, /// A [BatchMutation] where the consumer can apply the suppression comment pub mutation: &'a mut BatchMutation, - /// A string equals to "rome-ignore: lint(/)" + /// A string equals to "biome-ignore: lint(/)" pub suppression_text: &'a str, /// The original range of the diagnostic where the rule was triggered pub diagnostic_text_range: &'a TextRange, diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index 616f9013e7f6..1e9a12c7baba 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -14,8 +14,6 @@ use biome_service::{configuration::LoadedConfiguration, DynRef, Workspace, Works use std::ffi::OsString; pub(crate) struct CheckCommandPayload { - pub(crate) apply: bool, - pub(crate) apply_unsafe: bool, pub(crate) write: bool, pub(crate) fix: bool, pub(crate) unsafe_: bool, @@ -136,16 +134,11 @@ impl CommandRunner for CheckCommandPayload { console: &mut dyn Console, _workspace: &dyn Workspace, ) -> Result { - let fix_file_mode = determine_fix_file_mode( - FixFileModeOptions { - apply: self.apply, - apply_unsafe: self.apply_unsafe, - write: self.write, - fix: self.fix, - unsafe_: self.unsafe_, - }, - console, - )?; + let fix_file_mode = determine_fix_file_mode(FixFileModeOptions { + write: self.write, + fix: self.fix, + unsafe_: self.unsafe_, + })?; Ok(Execution::new(TraversalMode::Check { fix_file_mode, diff --git a/crates/biome_cli/src/commands/daemon.rs b/crates/biome_cli/src/commands/daemon.rs index 318a6a54282a..2541c2c0afea 100644 --- a/crates/biome_cli/src/commands/daemon.rs +++ b/crates/biome_cli/src/commands/daemon.rs @@ -232,11 +232,7 @@ fn setup_tracing_subscriber(log_path: Option, log_file_name_prefix: Opt pub fn default_biome_log_path() -> PathBuf { match env::var_os("BIOME_LOG_PATH") { Some(directory) => PathBuf::from(directory), - // TODO: Remove in Biome v2, and use the None part as fallback. - None => match env::var_os("BIOME_LOG_DIR") { - Some(directory) => PathBuf::from(directory), - None => biome_fs::ensure_cache_dir().join("biome-logs"), - }, + None => biome_fs::ensure_cache_dir().join("biome-logs"), } } diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index 6b876ff5691b..7102ba391cb9 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -1,6 +1,5 @@ use crate::cli_options::CliOptions; use crate::commands::{get_files_to_process_with_cli_options, CommandRunner, LoadEditorConfig}; -use crate::diagnostics::DeprecatedArgument; use crate::{CliDiagnostic, Execution, TraversalMode}; use biome_configuration::vcs::PartialVcsConfiguration; use biome_configuration::{ @@ -8,9 +7,8 @@ use biome_configuration::{ PartialFormatterConfiguration, PartialGraphqlFormatter, PartialJavascriptFormatter, PartialJsonFormatter, }; -use biome_console::{markup, Console, ConsoleExt}; +use biome_console::Console; use biome_deserialize::Merge; -use biome_diagnostics::PrintDiagnostic; use biome_fs::FileSystem; use biome_service::configuration::LoadedConfiguration; use biome_service::{DynRef, Workspace, WorkspaceError}; @@ -63,65 +61,6 @@ impl CommandRunner for FormatCommandPayload { fs_configuration.merge_with(biome_configuration); let mut configuration = fs_configuration; - // TODO: remove in biome 2.0 - if let Some(config) = self.formatter_configuration.as_mut() { - if let Some(indent_size) = config.indent_size { - let diagnostic = DeprecatedArgument::new(markup! { - "The argument ""--indent-size"" is deprecated, it will be removed in the next major release. Use ""--indent-width"" instead." - }); - console.error(markup! { - {PrintDiagnostic::simple(&diagnostic)} - }); - - if config.indent_width.is_none() { - config.indent_width = Some(indent_size); - } - } - } - // TODO: remove in biome 2.0 - if let Some(js_formatter) = self.javascript_formatter.as_mut() { - if let Some(indent_size) = js_formatter.indent_size { - let diagnostic = DeprecatedArgument::new(markup! { - "The argument ""--javascript-formatter-indent-size"" is deprecated, it will be removed in the next major release. Use ""--javascript-formatter-indent-width"" instead." - }); - console.error(markup! { - {PrintDiagnostic::simple(&diagnostic)} - }); - - if js_formatter.indent_width.is_none() { - js_formatter.indent_width = Some(indent_size); - } - } - - if let Some(trailing_comma) = js_formatter.trailing_comma { - let diagnostic = DeprecatedArgument::new(markup! { - "The argument ""--trailing-comma"" is deprecated, it will be removed in the next major release. Use ""--trailing-commas"" instead." - }); - console.error(markup! { - {PrintDiagnostic::simple(&diagnostic)} - }); - - if js_formatter.trailing_commas.is_none() { - js_formatter.trailing_commas = Some(trailing_comma); - } - } - } - // TODO: remove in biome 2.0 - if let Some(json_formatter) = self.json_formatter.as_mut() { - if let Some(indent_size) = json_formatter.indent_size { - let diagnostic = DeprecatedArgument::new(markup! { - "The argument ""--json-formatter-indent-size"" is deprecated, it will be removed in the next major release. Use ""--json-formatter-indent-width"" instead." - }); - console.error(markup! { - {PrintDiagnostic::simple(&diagnostic)} - }); - - if json_formatter.indent_width.is_none() { - json_formatter.indent_width = Some(indent_size); - } - } - } - // merge formatter options if !configuration .formatter diff --git a/crates/biome_cli/src/commands/lint.rs b/crates/biome_cli/src/commands/lint.rs index 065674b2e4c8..51088213bf72 100644 --- a/crates/biome_cli/src/commands/lint.rs +++ b/crates/biome_cli/src/commands/lint.rs @@ -19,8 +19,6 @@ use biome_service::{DynRef, Workspace, WorkspaceError}; use std::ffi::OsString; pub(crate) struct LintCommandPayload { - pub(crate) apply: bool, - pub(crate) apply_unsafe: bool, pub(crate) write: bool, pub(crate) fix: bool, pub(crate) unsafe_: bool, @@ -129,16 +127,11 @@ impl CommandRunner for LintCommandPayload { console: &mut dyn Console, _workspace: &dyn Workspace, ) -> Result { - let fix_file_mode = determine_fix_file_mode( - FixFileModeOptions { - apply: self.apply, - apply_unsafe: self.apply_unsafe, - write: self.write, - fix: self.fix, - unsafe_: self.unsafe_, - }, - console, - )?; + let fix_file_mode = determine_fix_file_mode(FixFileModeOptions { + write: self.write, + fix: self.fix, + unsafe_: self.unsafe_, + })?; Ok(Execution::new(TraversalMode::Lint { fix_file_mode, stdin: self.get_stdin(console)?, diff --git a/crates/biome_cli/src/commands/migrate.rs b/crates/biome_cli/src/commands/migrate.rs index ed29e23eb737..0de05216841c 100644 --- a/crates/biome_cli/src/commands/migrate.rs +++ b/crates/biome_cli/src/commands/migrate.rs @@ -79,8 +79,6 @@ impl CommandRunner for MigrateCommandPayload { fn check_incompatible_arguments(&self) -> Result<(), CliDiagnostic> { check_fix_incompatible_arguments(FixFileModeOptions { - apply: false, - apply_unsafe: false, write: self.write, fix: self.fix, unsafe_: false, diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 0101d9545236..68f7b3af6216 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -1,6 +1,5 @@ use crate::changed::{get_changed_files, get_staged_files}; use crate::cli_options::{cli_options, CliOptions, CliReporter, ColorsArg}; -use crate::diagnostics::{DeprecatedArgument, DeprecatedConfigurationFile}; use crate::execute::Stdin; use crate::logging::LoggingKind; use crate::{ @@ -22,7 +21,7 @@ use biome_configuration::{ }; use biome_configuration::{BiomeDiagnostic, PartialConfiguration}; use biome_console::{markup, Console, ConsoleExt}; -use biome_diagnostics::{Diagnostic, PrintDiagnostic}; +use biome_diagnostics::PrintDiagnostic; use biome_fs::{BiomePath, FileSystem}; use biome_service::configuration::{ load_configuration, load_editorconfig, LoadedConfiguration, PartialConfigurationExt, @@ -117,14 +116,6 @@ pub enum BiomeCommand { #[bpaf(long("fix"), switch, hide_usage)] fix: bool, - /// 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 (deprecated, use `--write --unsafe`) - #[bpaf(long("apply-unsafe"), switch, hide_usage)] - apply_unsafe: bool, - /// Allow to enable or disable the formatter check. #[bpaf( long("formatter-enabled"), @@ -195,14 +186,6 @@ pub enum BiomeCommand { #[bpaf(long("fix"), switch, hide_usage)] fix: bool, - /// 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 (deprecated, use `--write --unsafe`) - #[bpaf(long("apply-unsafe"), switch, hide_usage)] - apply_unsafe: bool, - #[bpaf(external(partial_linter_configuration), hide_usage, optional)] linter_configuration: Option, @@ -618,21 +601,6 @@ pub(crate) fn validate_configuration_diagnostics( console: &mut dyn Console, verbose: bool, ) -> Result<(), CliDiagnostic> { - if let Some(file_path) = loaded_configuration - .file_path - .as_ref() - .and_then(|f| f.file_name()) - .and_then(|f| f.to_str()) - { - if file_path == "rome.json" { - let diagnostic = DeprecatedConfigurationFile::new(file_path); - if diagnostic.tags().is_verbose() && verbose { - console.error(markup! {{PrintDiagnostic::verbose(&diagnostic)}}) - } else { - console.error(markup! {{PrintDiagnostic::simple(&diagnostic)}}) - } - } - } let diagnostics = loaded_configuration.as_diagnostics_iter(); for diagnostic in diagnostics { if diagnostic.tags().is_verbose() && verbose { @@ -700,8 +668,6 @@ fn get_files_to_process_with_cli_options( /// Holds the options to determine the fix file mode. pub(crate) struct FixFileModeOptions { - apply: bool, - apply_unsafe: bool, write: bool, fix: bool, unsafe_: bool, @@ -712,32 +678,17 @@ 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, ) -> Result, CliDiagnostic> { let FixFileModeOptions { - apply, - apply_unsafe, write, fix, 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; - let unsafe_fixes = apply_unsafe || ((write || safe_fixes) && unsafe_); + let safe_fixes = write || fix; + let unsafe_fixes = (write || safe_fixes) && unsafe_; if unsafe_fixes { Ok(Some(FixFileMode::SafeAndUnsafeFixes)) @@ -750,34 +701,8 @@ pub(crate) fn determine_fix_file_mode( /// Checks if the fix file options are incompatible. fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), CliDiagnostic> { - let FixFileModeOptions { - apply, - apply_unsafe, - write, - fix, - unsafe_, - } = options; - if apply && apply_unsafe { - return Err(CliDiagnostic::incompatible_arguments( - "--apply", - "--apply-unsafe", - )); - } else if apply_unsafe && unsafe_ { - return Err(CliDiagnostic::incompatible_arguments( - "--apply-unsafe", - "--unsafe", - )); - } else if apply && (fix || write) { - return Err(CliDiagnostic::incompatible_arguments( - "--apply", - if fix { "--fix" } else { "--write" }, - )); - } else if apply_unsafe && (fix || write) { - return Err(CliDiagnostic::incompatible_arguments( - "--apply-unsafe", - if fix { "--fix" } else { "--write" }, - )); - } else if write && fix { + let FixFileModeOptions { write, fix, .. } = options; + if write && fix { return Err(CliDiagnostic::incompatible_arguments("--write", "--fix")); } Ok(()) @@ -961,52 +886,30 @@ pub trait LoadEditorConfig: CommandRunner { #[cfg(test)] mod tests { - use biome_console::BufferConsole; - use super::*; #[test] fn incompatible_arguments() { - for (apply, apply_unsafe, write, fix, unsafe_) in [ - (true, true, false, false, false), // --apply --apply-unsafe - (true, false, true, false, false), // --apply --write - (true, false, false, true, false), // --apply --fix - (false, true, false, false, true), // --apply-unsafe --unsafe - (false, true, true, false, false), // --apply-unsafe --write - (false, true, false, true, false), // --apply-unsafe --fix - (false, false, true, true, false), // --write --fix - ] { - assert!(check_fix_incompatible_arguments(FixFileModeOptions { - apply, - apply_unsafe, - write, - fix, - unsafe_ - }) - .is_err()); - } + assert!(check_fix_incompatible_arguments(FixFileModeOptions { + write: true, + fix: true, + unsafe_: false + }) + .is_err()); } #[test] fn safe_fixes() { - let mut console = BufferConsole::default(); - - for (apply, apply_unsafe, write, fix, unsafe_) in [ - (true, false, false, false, false), // --apply - (false, false, true, false, false), // --write - (false, false, false, true, false), // --fix + for (write, fix, unsafe_) in [ + (true, false, false), // --write + (false, true, false), // --fix ] { assert_eq!( - determine_fix_file_mode( - FixFileModeOptions { - apply, - apply_unsafe, - write, - fix, - unsafe_ - }, - &mut console - ) + determine_fix_file_mode(FixFileModeOptions { + write, + fix, + unsafe_ + },) .unwrap(), Some(FixFileMode::SafeFixes) ); @@ -1015,24 +918,16 @@ mod tests { #[test] fn safe_and_unsafe_fixes() { - let mut console = BufferConsole::default(); - - for (apply, apply_unsafe, write, fix, unsafe_) in [ - (false, true, false, false, false), // --apply-unsafe - (false, false, true, false, true), // --write --unsafe - (false, false, false, true, true), // --fix --unsafe + for (write, fix, unsafe_) in [ + (true, false, true), // --write --unsafe + (false, true, true), // --fix --unsafe ] { assert_eq!( - determine_fix_file_mode( - FixFileModeOptions { - apply, - apply_unsafe, - write, - fix, - unsafe_ - }, - &mut console - ) + determine_fix_file_mode(FixFileModeOptions { + write, + fix, + unsafe_ + },) .unwrap(), Some(FixFileMode::SafeAndUnsafeFixes) ); @@ -1041,20 +936,13 @@ mod tests { #[test] fn no_fix() { - let mut console = BufferConsole::default(); - - let (apply, apply_unsafe, write, fix, unsafe_) = (false, false, false, false, false); + let (write, fix, unsafe_) = (false, false, false); assert_eq!( - determine_fix_file_mode( - FixFileModeOptions { - apply, - apply_unsafe, - write, - fix, - unsafe_ - }, - &mut console - ) + determine_fix_file_mode(FixFileModeOptions { + write, + fix, + unsafe_ + },) .unwrap(), None ); diff --git a/crates/biome_cli/src/diagnostics.rs b/crates/biome_cli/src/diagnostics.rs index 48aa995f8261..d5ea6a456ff0 100644 --- a/crates/biome_cli/src/diagnostics.rs +++ b/crates/biome_cli/src/diagnostics.rs @@ -1,4 +1,3 @@ -use biome_console::fmt::Display; use biome_console::markup; use biome_diagnostics::adapters::{BpafError, IoError, SerdeJsonError}; use biome_diagnostics::{ @@ -258,14 +257,6 @@ pub struct DeprecatedArgument { pub message: MessageAndDescription, } -impl DeprecatedArgument { - pub fn new(message: impl Display) -> Self { - Self { - message: MessageAndDescription::from(markup! {{message}}.to_owned()), - } - } -} - #[derive(Debug, Diagnostic)] pub enum ReportDiagnostic { /// Emitted when trying to serialise the report @@ -475,26 +466,6 @@ impl Termination for CliDiagnostic { } } -#[derive(Debug, Diagnostic)] -#[diagnostic( -category = "internalError/fs", - severity = Warning, - message( - description = "The configuration file {path} is deprecated. Use biome.json instead.", - message("The configuration file "{self.path}" is deprecated. Use ""biome.json"" instead."), - ) -)] -pub struct DeprecatedConfigurationFile { - #[location(resource)] - pub path: String, -} - -impl DeprecatedConfigurationFile { - pub fn new(path: impl Into) -> Self { - Self { path: path.into() } - } -} - #[derive(Debug, Default, Diagnostic)] #[diagnostic( severity = Error, diff --git a/crates/biome_cli/src/execute/migrate/prettier.rs b/crates/biome_cli/src/execute/migrate/prettier.rs index eae4d3231e91..4d86c44b97dd 100644 --- a/crates/biome_cli/src/execute/migrate/prettier.rs +++ b/crates/biome_cli/src/execute/migrate/prettier.rs @@ -212,8 +212,6 @@ impl TryFrom for biome_configuration::PartialConfiguratio // editorconfig support is intentionally set to true, because prettier always reads the editorconfig file // see: https://github.com/prettier/prettier/issues/15255 use_editorconfig: Some(true), - // deprecated - indent_size: None, bracket_spacing: Some(BracketSpacing::default()), }; result.formatter = Some(formatter); @@ -239,16 +237,11 @@ impl TryFrom for biome_configuration::PartialConfiguratio indent_style: None, line_ending: None, enabled: None, - // deprecated - indent_size: None, - // js ones bracket_same_line: Some(value.bracket_line), arrow_parentheses: Some(value.arrow_parens.into()), semicolons: Some(semicolons), trailing_commas: Some(value.trailing_comma.into()), - // deprecated - trailing_comma: None, quote_style: Some(quote_style), quote_properties: Some(value.quote_props.into()), bracket_spacing: Some(value.bracket_spacing.into()), diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index ca7fff6a4ab6..afeab7dbda23 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -6,7 +6,7 @@ //! to parse commands and arguments, redirect the execution of the commands and //! execute the traversal of directory and files, based on the command that were passed. -use biome_console::{markup, ColorMode, Console, ConsoleExt}; +use biome_console::{ColorMode, Console}; use biome_fs::OsFileSystem; use biome_service::{App, DynRef, Workspace, WorkspaceRef}; use commands::search::SearchCommandPayload; @@ -69,12 +69,6 @@ impl<'app> CliSession<'app> { if has_metrics { crate::metrics::init_metrics(); } - // TODO: remove in Biome v2 - if env::var_os("BIOME_LOG_DIR").is_some() { - self.app.console.log(markup! { - "The use of BIOME_LOG_DIR is deprecated. Use BIOME_LOG_PATH instead." - }); - } let result = match command { BiomeCommand::Version(_) => commands::version::full_version(self), @@ -89,8 +83,6 @@ impl<'app> CliSession<'app> { } => commands::daemon::start(self, config_path, Some(log_path), Some(log_prefix_name)), BiomeCommand::Stop => commands::daemon::stop(self), BiomeCommand::Check { - apply, - apply_unsafe, write, fix, unsafe_, @@ -109,8 +101,6 @@ impl<'app> CliSession<'app> { self, &cli_options, CheckCommandPayload { - apply_unsafe, - apply, write, fix, unsafe_, @@ -127,8 +117,6 @@ impl<'app> CliSession<'app> { }, ), BiomeCommand::Lint { - apply, - apply_unsafe, write, fix, unsafe_, @@ -151,8 +139,6 @@ impl<'app> CliSession<'app> { self, &cli_options, LintCommandPayload { - apply_unsafe, - apply, write, fix, unsafe_, diff --git a/crates/biome_cli/tests/cases/biome_json_support.rs b/crates/biome_cli/tests/cases/biome_json_support.rs index a2c9eb79cb06..b39a58e96fb1 100644 --- a/crates/biome_cli/tests/cases/biome_json_support.rs +++ b/crates/biome_cli/tests/cases/biome_json_support.rs @@ -40,7 +40,7 @@ fn formatter_biome_json() { ("10"), ("--indent-style"), ("space"), - ("--indent-size"), + ("--indent-width"), ("8"), ("--write"), file_path.as_os_str().to_str().unwrap(), @@ -91,7 +91,7 @@ fn linter_biome_json() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -147,7 +147,7 @@ fn check_biome_json() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .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 714f86ebd0bf..77afb0f4d530 100644 --- a/crates/biome_cli/tests/cases/handle_astro_files.rs +++ b/crates/biome_cli/tests/cases/handle_astro_files.rs @@ -271,7 +271,8 @@ fn lint_and_fix_astro_files() { Args::from( [ ("lint"), - "--apply-unsafe", + "--write", + "--unsafe", astro_file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -342,7 +343,7 @@ fn sorts_imports_write() { ("check"), "--formatter-enabled=false", "--linter-enabled=false", - "--apply", + "--write", astro_file_path.as_os_str().to_str().unwrap(), ] .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 3ba2d52fb78f..0e5f2785b619 100644 --- a/crates/biome_cli/tests/cases/handle_svelte_files.rs +++ b/crates/biome_cli/tests/cases/handle_svelte_files.rs @@ -133,7 +133,7 @@ fn sorts_imports_write() { ("check"), "--formatter-enabled=false", "--linter-enabled=false", - "--apply", + "--write", svelte_file_path.as_os_str().to_str().unwrap(), ] .as_slice(), diff --git a/crates/biome_cli/tests/cases/handle_vue_files.rs b/crates/biome_cli/tests/cases/handle_vue_files.rs index da261f14b810..8223a52294d2 100644 --- a/crates/biome_cli/tests/cases/handle_vue_files.rs +++ b/crates/biome_cli/tests/cases/handle_vue_files.rs @@ -569,7 +569,7 @@ fn sorts_imports_write() { ("check"), "--formatter-enabled=false", "--linter-enabled=false", - "--apply", + "--write", vue_file_path.as_os_str().to_str().unwrap(), ] .as_slice(), diff --git a/crates/biome_cli/tests/cases/included_files.rs b/crates/biome_cli/tests/cases/included_files.rs index f415893064bc..3d129273db5c 100644 --- a/crates/biome_cli/tests/cases/included_files.rs +++ b/crates/biome_cli/tests/cases/included_files.rs @@ -190,7 +190,7 @@ fn does_not_handle_included_files_if_overridden_by_ignore_linter() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), test.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -241,7 +241,7 @@ fn does_not_handle_included_files_if_overridden_by_organize_imports() { Args::from( [ ("check"), - ("--apply"), + ("--write"), test.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] diff --git a/crates/biome_cli/tests/cases/overrides_linter.rs b/crates/biome_cli/tests/cases/overrides_linter.rs index 635ffe8ef07f..1d80704d62e1 100644 --- a/crates/biome_cli/tests/cases/overrides_linter.rs +++ b/crates/biome_cli/tests/cases/overrides_linter.rs @@ -45,7 +45,7 @@ fn does_handle_included_file_and_disable_linter() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), test.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -96,7 +96,8 @@ fn does_include_file_with_different_rules() { Args::from( [ ("lint"), - ("--apply-unsafe"), + "--write", + "--unsafe", test.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -170,7 +171,8 @@ fn does_include_file_with_different_linting_and_applies_all_of_them() { Args::from( [ ("lint"), - ("--apply-unsafe"), + "--write", + "--unsafe", test.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -244,7 +246,8 @@ fn does_include_file_with_different_overrides() { Args::from( [ ("lint"), - ("--apply-unsafe"), + "--write", + "--unsafe", test.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -306,7 +309,8 @@ fn does_override_the_rules() { Args::from( [ ("lint"), - ("--apply-unsafe"), + "--write", + "--unsafe", test.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -364,7 +368,8 @@ fn does_not_change_linting_settings() { Args::from( [ ("lint"), - ("--apply-unsafe"), + "--write", + "--unsafe", test.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -422,7 +427,7 @@ fn does_override_recommended() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(["lint", "--apply-unsafe", "."].as_slice()), + Args::from(["lint", "--write", "--unsafe", "."].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -478,7 +483,7 @@ fn does_override_groupe_recommended() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(["lint", "--apply-unsafe", "."].as_slice()), + Args::from(["lint", "--write", "--unsafe", "."].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -532,7 +537,7 @@ fn does_preserve_group_recommended_when_override_global_recommened() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(["lint", "--apply-unsafe", "."].as_slice()), + Args::from(["lint", "--write", "--unsafe", "."].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -586,7 +591,7 @@ fn does_preserve_individually_diabled_rules_in_overrides() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(["lint", "--apply-unsafe", "."].as_slice()), + Args::from(["lint", "--write", "--unsafe", "."].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 8601a681f74e..4ed3204e34d0 100644 --- a/crates/biome_cli/tests/cases/overrides_organize_imports.rs +++ b/crates/biome_cli/tests/cases/overrides_organize_imports.rs @@ -41,7 +41,7 @@ fn does_handle_included_file_and_disable_organize_imports() { Args::from( [ ("check"), - ("--apply"), + ("--write"), "--formatter-enabled=false", "--linter-enabled=false", test.as_os_str().to_str().unwrap(), diff --git a/crates/biome_cli/tests/commands/check.rs b/crates/biome_cli/tests/commands/check.rs index f316c07cdc17..d33d4a10360e 100644 --- a/crates/biome_cli/tests/commands/check.rs +++ b/crates/biome_cli/tests/commands/check.rs @@ -219,7 +219,7 @@ fn apply_ok() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -259,7 +259,7 @@ fn apply_noop() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -291,15 +291,15 @@ fn apply_suggested_error() { Args::from( [ ("check"), - ("--apply-unsafe"), - ("--apply"), + ("--unsafe"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), ), ); - assert!(result.is_err(), "run_cli returned {result:?}"); + assert!(result.is_ok(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( module_path!(), @@ -324,7 +324,8 @@ fn apply_suggested() { Args::from( [ ("check"), - ("--apply-unsafe"), + "--write", + "--unsafe", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -379,7 +380,8 @@ function f() {\n\targuments;\n} Args::from( [ ("check"), - ("--apply-unsafe"), + "--write", + "--unsafe", test1.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -418,7 +420,7 @@ fn no_lint_if_linter_is_disabled_when_run_apply() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -461,7 +463,7 @@ fn no_lint_if_linter_is_disabled_when_run_apply_biome_jsonc() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -540,7 +542,7 @@ fn should_disable_a_rule() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -586,7 +588,7 @@ fn should_disable_a_rule_group() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -720,7 +722,7 @@ fn no_lint_when_file_is_ignored() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -778,7 +780,7 @@ fn no_lint_if_files_are_listed_in_ignore_option() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path_test1.as_os_str().to_str().unwrap(), file_path_test2.as_os_str().to_str().unwrap(), ] @@ -972,7 +974,7 @@ fn fs_error_read_only() { Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -1091,7 +1093,7 @@ fn fs_files_ignore_symlink() { check_windows_symlink!(symlink_dir(&testcase2_path, symlink_testcase2_path)); } - let config_path = root_path.join("rome.json"); + let config_path = root_path.join("biome.json"); let mut config_file = File::create(config_path).unwrap(); config_file .write_all(CONFIG_IGNORE_SYMLINK.as_bytes()) @@ -1117,7 +1119,8 @@ fn fs_files_ignore_symlink() { ("check"), ("--config-path"), (root_path.display().to_string().as_str()), - ("--apply-unsafe"), + "--write", + "--unsafe", (src_path.display().to_string().as_str()), ] .as_slice(), @@ -1383,7 +1386,7 @@ fn deprecated_suppression_comment() { let file_path = Path::new("file.js"); fs.insert( file_path.into(), - *b"// rome-ignore lint(suspicious/noDoubleEquals): test + *b"// biome-ignore lint(suspicious/noDoubleEquals): test a == b;", ); @@ -1530,7 +1533,7 @@ fn suppression_syntax_error() { let mut console = BufferConsole::default(); let file_path = Path::new("check.js"); - fs.insert(file_path.into(), *b"// rome-ignore(:\n"); + fs.insert(file_path.into(), *b"// biome-ignore(:\n"); let result = run_cli( DynRef::Borrowed(&mut fs), @@ -1621,7 +1624,7 @@ import * as something from "../something"; let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(["check", "--apply", file_path.as_os_str().to_str().unwrap()].as_slice()), + Args::from(["check", "--write", file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1687,7 +1690,7 @@ import * as something from "../something"; Args::from( [ ("check"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -1729,7 +1732,8 @@ import * as something from "../something"; Args::from( [ ("check"), - ("--apply-unsafe"), + "--write", + "--unsafe", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -1770,7 +1774,7 @@ import * as something from "../something"; Args::from( [ ("check"), - ("--apply"), + ("--write"), ("--formatter-enabled=false"), ("--linter-enabled=false"), ("--organize-imports-enabled=true"), @@ -2054,7 +2058,8 @@ ignored/** ("--vcs-client-kind=git"), ("--vcs-use-ignore-file=true"), ("--vcs-root=."), - ("--apply-unsafe"), + "--write", + "--unsafe", file_path1.as_os_str().to_str().unwrap(), file_path2.as_os_str().to_str().unwrap(), ] @@ -2597,7 +2602,8 @@ fn apply_bogus_argument() { [ ("check"), file_path.as_os_str().to_str().unwrap(), - ("--apply-unsafe"), + "--write", + "--unsafe", ] .as_slice(), ), @@ -2751,7 +2757,8 @@ A = 0; Args::from( [ ("check"), - "--apply-unsafe", + "--write", + "--unsafe", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -2807,7 +2814,8 @@ A = 0; Args::from( [ ("check"), - "--apply-unsafe", + "--write", + "--unsafe", "--error-on-warnings", file_path.as_os_str().to_str().unwrap(), ] @@ -2845,7 +2853,8 @@ fn use_literal_keys_should_emit_correct_ast_issue_266() { Args::from( [ ("check"), - "--apply-unsafe", + "--write", + "--unsafe", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -2926,7 +2935,8 @@ fn print_json() { Args::from( [ ("check"), - ("--apply-unsafe"), + "--write", + "--unsafe", "--reporter=json", file_path.as_os_str().to_str().unwrap(), ] @@ -2959,7 +2969,8 @@ fn print_json_pretty() { Args::from( [ ("check"), - ("--apply-unsafe"), + "--write", + "--unsafe", "--reporter=json-pretty", file_path.as_os_str().to_str().unwrap(), ] @@ -3122,7 +3133,7 @@ fn fix_suggested_error() { [ ("check"), ("--fix"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -3306,7 +3317,7 @@ fn write_suggested_error() { [ ("check"), ("--write"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), diff --git a/crates/biome_cli/tests/commands/format.rs b/crates/biome_cli/tests/commands/format.rs index 86cb66284ba0..9ea57ba7b5fd 100644 --- a/crates/biome_cli/tests/commands/format.rs +++ b/crates/biome_cli/tests/commands/format.rs @@ -395,7 +395,7 @@ fn custom_config_file_path() { let mut fs = MemoryFileSystem::default(); let mut console = BufferConsole::default(); - let config_path = Path::new("/test/rome.json"); + let config_path = Path::new("/test/biome.json"); fs.insert(config_path.into(), CONFIG_FORMAT.as_bytes()); let file_path = Path::new("file.js"); @@ -491,7 +491,7 @@ fn applies_custom_configuration() { ("10"), ("--indent-style"), ("space"), - ("--indent-size"), + ("--indent-width"), ("8"), ("--write"), file_path.as_os_str().to_str().unwrap(), @@ -534,7 +534,7 @@ fn applies_custom_configuration_over_config_file() { ("10"), ("--indent-style"), ("space"), - ("--indent-size"), + ("--indent-width"), ("8"), ("--write"), file_path.as_os_str().to_str().unwrap(), @@ -789,80 +789,6 @@ fn applies_custom_trailing_commas() { )); } -#[test] -fn applies_custom_trailing_commas_using_the_deprecated_option() { - let mut fs = MemoryFileSystem::default(); - let mut console = BufferConsole::default(); - - let file_path = Path::new("file.js"); - fs.insert(file_path.into(), APPLY_TRAILING_COMMAS_BEFORE.as_bytes()); - - let result = run_cli( - DynRef::Borrowed(&mut fs), - &mut console, - Args::from( - [ - ("format"), - ("--trailing-comma"), - ("none"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), - ); - - assert!(result.is_ok(), "run_cli returned {result:?}"); - - assert_file_contents(&fs, file_path, APPLY_TRAILING_COMMAS_AFTER); - - assert_cli_snapshot(SnapshotPayload::new( - module_path!(), - "applies_custom_trailing_commas_using_the_deprecated_option", - fs, - console, - result, - )); -} - -#[test] -fn applies_custom_trailing_commas_overriding_the_deprecated_option() { - let mut fs = MemoryFileSystem::default(); - let mut console = BufferConsole::default(); - - let file_path = Path::new("file.js"); - fs.insert(file_path.into(), APPLY_TRAILING_COMMAS_BEFORE.as_bytes()); - - let result = run_cli( - DynRef::Borrowed(&mut fs), - &mut console, - Args::from( - [ - ("format"), - ("--trailing-commas"), - ("none"), - ("--trailing-comma"), - ("all"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), - ); - - assert!(result.is_ok(), "run_cli returned {result:?}"); - - assert_file_contents(&fs, file_path, APPLY_TRAILING_COMMAS_AFTER); - - assert_cli_snapshot(SnapshotPayload::new( - module_path!(), - "applies_custom_trailing_commas_overriding_the_deprecated_option", - fs, - console, - result, - )); -} - #[test] fn applies_custom_attribute_position() { let mut fs = MemoryFileSystem::default(); @@ -1116,7 +1042,7 @@ fn indent_size_parse_errors_negative() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from([("format"), ("--indent-size=-1"), ("file.js")].as_slice()), + Args::from([("format"), ("--indent-width=-1"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1138,7 +1064,7 @@ fn indent_size_parse_errors_overflow() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from([("format"), ("--indent-size=257"), ("file.js")].as_slice()), + Args::from([("format"), ("--indent-width=257"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2631,13 +2557,13 @@ fn should_apply_different_formatting() { "javascript": { "formatter": { "lineWidth": 320, - "indentSize": 8 + "indentWidth": 8 } }, "json": { "formatter": { "lineWidth": 80, - "indentSize": 2 + "indentWidth": 2 } }, "css": { @@ -2737,9 +2663,9 @@ const a = { ("format"), "--write", "--javascript-formatter-line-width=320", - "--javascript-formatter-indent-size=8", + "--javascript-formatter-indent-width=8", "--json-formatter-line-width=20", - "--json-formatter-indent-size=2", + "--json-formatter-indent-width=2", "--css-formatter-line-width=40", "--css-formatter-indent-width=6", "--css-formatter-enabled=true", @@ -2777,7 +2703,7 @@ fn should_not_format_json_files_if_disabled() { "javascript": { "formatter": { "lineWidth": 80, - "indentSize": 4 + "indentWidth": 4 } }, "json": { @@ -2851,7 +2777,7 @@ fn should_not_format_js_files_if_disabled() { "json": { "formatter": { "lineWidth": 80, - "indentSize": 2 + "indentWidth": 2 } } }"#, @@ -2915,7 +2841,7 @@ fn should_not_format_css_files_if_disabled() { "javascript": { "formatter": { "lineWidth": 80, - "indentSize": 4 + "indentWidth": 4 } }, "css": { @@ -2983,14 +2909,14 @@ fn should_apply_different_indent_style() { "javascript": { "formatter": { "lineWidth": 320, - "indentSize": 8, + "indentWidth": 8, "indentStyle": "tab" } }, "json": { "formatter": { "lineWidth": 80, - "indentSize": 2, + "indentWidth": 2, "indentStyle": "tab" } } diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs index 6766573da5a0..f43ab9014172 100644 --- a/crates/biome_cli/tests/commands/lint.rs +++ b/crates/biome_cli/tests/commands/lint.rs @@ -190,7 +190,7 @@ fn apply_ok() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -230,7 +230,7 @@ fn apply_noop() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -262,15 +262,15 @@ fn apply_suggested_error() { Args::from( [ ("lint"), - ("--apply-unsafe"), - ("--apply"), + "--write", + "--unsafe", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), ), ); - assert!(result.is_err(), "run_cli returned {result:?}"); + assert!(result.is_ok(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( module_path!(), @@ -295,7 +295,8 @@ fn apply_suggested() { Args::from( [ ("lint"), - ("--apply-unsafe"), + "--write", + "--unsafe", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -350,7 +351,8 @@ function f() { arguments; } Args::from( [ ("lint"), - ("--apply-unsafe"), + "--write", + "--unsafe", test1.as_os_str().to_str().unwrap(), test2.as_os_str().to_str().unwrap(), ] @@ -389,7 +391,7 @@ fn no_lint_if_linter_is_disabled_when_run_apply() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -432,7 +434,7 @@ fn no_lint_if_linter_is_disabled_when_run_apply_biome_jsonc() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -511,7 +513,7 @@ fn should_disable_a_rule() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -557,7 +559,7 @@ fn should_disable_a_rule_group() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -744,7 +746,7 @@ fn no_lint_when_file_is_ignored() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -790,7 +792,7 @@ fn no_lint_if_files_are_listed_in_ignore_option() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path_test1.as_os_str().to_str().unwrap(), file_path_test2.as_os_str().to_str().unwrap(), ] @@ -998,7 +1000,7 @@ fn fs_error_read_only() { Args::from( [ ("lint"), - ("--apply"), + ("--write"), file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -1118,7 +1120,7 @@ fn fs_files_ignore_symlink() { check_windows_symlink!(symlink_dir(&testcase2_path, symlink_testcase2_path)); } - let config_path = root_path.join("rome.json"); + let config_path = root_path.join("biome.json"); let mut config_file = File::create(config_path).unwrap(); config_file .write_all(CONFIG_IGNORE_SYMLINK.as_bytes()) @@ -1144,7 +1146,8 @@ fn fs_files_ignore_symlink() { ("lint"), ("--config-path"), (root_path.display().to_string().as_str()), - ("--apply-unsafe"), + "--write", + "--unsafe", (src_path.display().to_string().as_str()), ] .as_slice(), @@ -1564,7 +1567,7 @@ fn deprecated_suppression_comment() { let file_path = Path::new("file.js"); fs.insert( file_path.into(), - *b"// rome-ignore lint(suspicious/noDoubleEquals): test + *b"// biome-ignore lint(suspicious/noDoubleEquals): test a == b;", ); @@ -1678,7 +1681,7 @@ fn suppression_syntax_error() { let mut console = BufferConsole::default(); let file_path = Path::new("check.js"); - fs.insert(file_path.into(), *b"// rome-ignore(:\n"); + fs.insert(file_path.into(), *b"// biome-ignore(:\n"); let result = run_cli( DynRef::Borrowed(&mut fs), @@ -2528,7 +2531,8 @@ fn apply_bogus_argument() { [ ("lint"), file_path.as_os_str().to_str().unwrap(), - ("--apply-unsafe"), + "--write", + "--unsafe", ] .as_slice(), ), @@ -2679,7 +2683,7 @@ A = 0; let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from([("lint"), "--apply-unsafe", ("file.js")].as_slice()), + Args::from([("lint"), "--write", "--unsafe", ("file.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2731,7 +2735,8 @@ A = 0; Args::from( [ ("lint"), - "--apply-unsafe", + "--write", + "--unsafe", "--error-on-warnings", file_path.as_os_str().to_str().unwrap(), ] diff --git a/crates/biome_cli/tests/commands/migrate.rs b/crates/biome_cli/tests/commands/migrate.rs index e8b8e60c93a1..ee7076d0f1ce 100644 --- a/crates/biome_cli/tests/commands/migrate.rs +++ b/crates/biome_cli/tests/commands/migrate.rs @@ -79,60 +79,6 @@ fn missing_configuration_file() { )); } -#[test] -fn emit_diagnostic_for_rome_json() { - let mut fs = MemoryFileSystem::default(); - let mut console = BufferConsole::default(); - - let configuration = r#"{ "linter": { "enabled": true } }"#; - - let configuration_path = Path::new("rome.json"); - fs.insert(configuration_path.into(), configuration.as_bytes()); - - let result = run_cli( - DynRef::Borrowed(&mut fs), - &mut console, - Args::from([("migrate")].as_slice()), - ); - - assert!(result.is_ok(), "run_cli returned {result:?}"); - - assert_cli_snapshot(SnapshotPayload::new( - module_path!(), - "emit_diagnostic_for_rome_json", - fs, - console, - result, - )); -} - -#[test] -fn should_create_biome_json_file() { - let mut fs = MemoryFileSystem::default(); - let mut console = BufferConsole::default(); - - let configuration = r#"{ "linter": { "enabled": true } }"#; - - let configuration_path = Path::new("rome.json"); - fs.insert(configuration_path.into(), configuration.as_bytes()); - - let result = run_cli( - DynRef::Borrowed(&mut fs), - &mut console, - Args::from([("migrate"), "--write"].as_slice()), - ); - - assert!(result.is_ok(), "run_cli returned {result:?}"); - - assert_cli_snapshot(SnapshotPayload::new( - module_path!(), - "should_create_biome_json_file", - fs, - console, - result, - )); -} - #[test] fn should_emit_incompatible_arguments_error() { let mut fs = MemoryFileSystem::default(); diff --git a/crates/biome_cli/tests/commands/rage.rs b/crates/biome_cli/tests/commands/rage.rs index 207878bac9a8..97c367d8b56f 100644 --- a/crates/biome_cli/tests/commands/rage.rs +++ b/crates/biome_cli/tests/commands/rage.rs @@ -349,8 +349,8 @@ fn assert_rage_snapshot(payload: SnapshotPayload<'_>) { .lines() .map(|line| match line.trim_start().split_once(':') { Some(( - "CPU Architecture" | "OS" | "NO_COLOR" | "TERM" | "BIOME_LOG_DIR" - | "BIOME_LOG_PATH" | "Color support", + "CPU Architecture" | "OS" | "NO_COLOR" | "TERM" | "BIOME_LOG_PATH" + | "Color support", value, )) => line.replace(value.trim_start(), "**PLACEHOLDER**"), _ => line.to_string(), diff --git a/crates/biome_cli/tests/configs.rs b/crates/biome_cli/tests/configs.rs index b58e1d9660b2..db07b2a8bc7a 100644 --- a/crates/biome_cli/tests/configs.rs +++ b/crates/biome_cli/tests/configs.rs @@ -3,7 +3,7 @@ pub const CONFIG_FORMAT: &str = r#"{ "enabled": true, "lineWidth": 160, "indentStyle": "space", - "indentSize": 6 + "indentWidth": 6 } } "#; @@ -38,7 +38,7 @@ pub const CONFIG_ALL_FIELDS: &str = r#"{ "enabled": true, "formatWithErrors": true, "indentStyle": "tab", - "indentSize": 2, + "indentWidth": 2, "lineWidth": 80 }, "linter": { @@ -192,7 +192,7 @@ pub const CONFIG_INCORRECT_GLOBALS_V2: &str = r#"{ pub const CONFIG_ISSUE_3175_1: &str = r#"{ "formatter": { "indentStyle": "space", - "indentSize": 2, + "indentWidth": 2, "lineWidth": 120 } }"#; 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 3d460868d68a..02f41fb8870c 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,14 +26,6 @@ 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