diff --git a/crates/biome_cli/src/commands/rage.rs b/crates/biome_cli/src/commands/rage.rs index a7d7fdfbf016..057c6ec1fec3 100644 --- a/crates/biome_cli/src/commands/rage.rs +++ b/crates/biome_cli/src/commands/rage.rs @@ -217,6 +217,7 @@ impl Display for RageConfiguration<'_, '_> { {KeyValuePair("Line ending", markup!({DebugDisplay(formatter_configuration.line_ending)}))} {KeyValuePair("Line width", markup!({DebugDisplay(formatter_configuration.line_width.value())}))} {KeyValuePair("Attribute position", markup!({DebugDisplay(formatter_configuration.attribute_position)}))} + {KeyValuePair("Bracket spacing", markup!({DebugDisplay(formatter_configuration.bracket_spacing)}))} {KeyValuePair("Ignore", markup!({DebugDisplay(formatter_configuration.ignore.iter().collect::>())}))} {KeyValuePair("Include", markup!({DebugDisplay(formatter_configuration.include.iter().collect::>())}))} ).fmt(fmt)?; @@ -231,14 +232,14 @@ impl Display for RageConfiguration<'_, '_> { {KeyValuePair("Trailing commas", markup!({DebugDisplay(javascript_formatter_configuration.trailing_commas)}))} {KeyValuePair("Semicolons", markup!({DebugDisplay(javascript_formatter_configuration.semicolons)}))} {KeyValuePair("Arrow parentheses", markup!({DebugDisplay(javascript_formatter_configuration.arrow_parentheses)}))} - {KeyValuePair("Bracket spacing", markup!({DebugDisplay(javascript_formatter_configuration.bracket_spacing)}))} + {KeyValuePair("Bracket spacing", markup!({DebugDisplayOption(javascript_formatter_configuration.bracket_spacing)}))} {KeyValuePair("Bracket same line", markup!({DebugDisplay(javascript_formatter_configuration.bracket_same_line)}))} {KeyValuePair("Quote style", markup!({DebugDisplay(javascript_formatter_configuration.quote_style)}))} {KeyValuePair("Indent style", markup!({DebugDisplayOption(javascript_formatter_configuration.indent_style)}))} {KeyValuePair("Indent width", markup!({DebugDisplayOption(javascript_formatter_configuration.indent_width)}))} {KeyValuePair("Line ending", markup!({DebugDisplayOption(javascript_formatter_configuration.line_ending)}))} {KeyValuePair("Line width", markup!({DebugDisplayOption(javascript_formatter_configuration.line_width.map(|lw| lw.value()))}))} - {KeyValuePair("Attribute position", markup!({DebugDisplay(javascript_formatter_configuration.attribute_position)}))} + {KeyValuePair("Attribute position", markup!({DebugDisplayOption(javascript_formatter_configuration.attribute_position)}))} ) .fmt(fmt)?; @@ -275,7 +276,8 @@ impl Display for RageConfiguration<'_, '_> { {KeyValuePair("Indent width", markup!({DebugDisplayOption(graphql_formatter_configuration.indent_width)}))} {KeyValuePair("Line ending", markup!({DebugDisplayOption(graphql_formatter_configuration.line_ending)}))} {KeyValuePair("Line width", markup!({DebugDisplayOption(graphql_formatter_configuration.line_width)}))} - {KeyValuePair("Quote style", markup!({DebugDisplay(graphql_formatter_configuration.quote_style)}))} + {KeyValuePair("Bracket spacing", markup!({DebugDisplayOption(graphql_formatter_configuration.bracket_spacing)}))} + {KeyValuePair("Quote style", markup!({DebugDisplayOption(graphql_formatter_configuration.quote_style)}))} ).fmt(fmt)?; } diff --git a/crates/biome_cli/src/execute/migrate/prettier.rs b/crates/biome_cli/src/execute/migrate/prettier.rs index 4a4037c2c36b..ee23347c6014 100644 --- a/crates/biome_cli/src/execute/migrate/prettier.rs +++ b/crates/biome_cli/src/execute/migrate/prettier.rs @@ -5,7 +5,8 @@ use biome_deserialize::{json::deserialize_from_json_str, StringSet}; use biome_deserialize_macros::Deserializable; use biome_diagnostics::{DiagnosticExt, PrintDiagnostic}; use biome_formatter::{ - AttributePosition, IndentWidth, LineEnding, LineWidth, ParseFormatNumberError, QuoteStyle, + AttributePosition, BracketSpacing, IndentWidth, LineEnding, LineWidth, ParseFormatNumberError, + QuoteStyle, }; use biome_fs::{FileSystem, OpenOptions}; use biome_js_formatter::context::{ArrowParentheses, QuoteProperties, Semicolons, TrailingCommas}; @@ -210,6 +211,7 @@ impl TryFrom for biome_configuration::PartialConfiguratio enabled: Some(true), // deprecated indent_size: None, + bracket_spacing: Some(BracketSpacing::default()), }; result.formatter = Some(formatter); @@ -246,7 +248,7 @@ impl TryFrom for biome_configuration::PartialConfiguratio trailing_comma: None, quote_style: Some(quote_style), quote_properties: Some(value.quote_props.into()), - bracket_spacing: Some(value.bracket_spacing), + bracket_spacing: Some(value.bracket_spacing.into()), jsx_quote_style: Some(jsx_quote_style), attribute_position: Some(AttributePosition::default()), }; @@ -349,7 +351,6 @@ impl TryFrom for biome_configuration::OverridePattern { .map(|trailing_comma| trailing_comma.into()), quote_style, quote_properties: options.quote_props.map(|quote_props| quote_props.into()), - bracket_spacing: options.bracket_spacing, jsx_quote_style, ..Default::default() }; diff --git a/crates/biome_cli/tests/commands/format.rs b/crates/biome_cli/tests/commands/format.rs index 2575f8cf9cd0..27485b120dcf 100644 --- a/crates/biome_cli/tests/commands/format.rs +++ b/crates/biome_cli/tests/commands/format.rs @@ -121,6 +121,17 @@ let foo = {a, b}; const {a, b} = foo; "#; +const APPLY_BRACKET_SPACING_BEFORE_GRAPHQL: &str = r#"{ + field_value( + object_value: {key: "value"} + ) +}"#; + +const APPLY_BRACKET_SPACING_AFTER_GRAPHQL: &str = r#"{ + field_value(object_value: {key: "value"}) +} +"#; + const APPLY_BRACKET_SAME_LINE_BEFORE: &str = r#" The attribute position style in HTMLish languages. By default auto. + --bracket-spacing= Whether to insert spaces around brackets in object literals. + Defaults to true. --jsx-quote-style= The type of quotes used in JSX. Defaults to double. --quote-properties= When properties in objects are quoted. Defaults to asNeeded. --trailing-comma= Print trailing commas wherever possible in multi-line comma-separated @@ -41,8 +43,6 @@ The configuration that is contained inside the file `biome.json` only in for statements where it is necessary because of ASI. --arrow-parentheses= Whether to add non-necessary parentheses to arrow functions. Defaults to "always". - --bracket-spacing= Whether to insert spaces around brackets in object literals. - Defaults to true. --bracket-same-line= Whether to hug the closing bracket of multiline HTML/JSX tags to the end of the last line, rather than being alone on the following line. Defaults to false. diff --git a/crates/biome_cli/tests/snapshots/main_commands_ci/ci_help.snap b/crates/biome_cli/tests/snapshots/main_commands_ci/ci_help.snap index 9751fcc0f32c..67c599192fec 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_ci/ci_help.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_ci/ci_help.snap @@ -33,6 +33,8 @@ The configuration that is contained inside the file `biome.json` --line-width=NUMBER What's the max width of a line. Defaults to 80. --attribute-position= The attribute position style in HTMLish languages. By default auto. + --bracket-spacing= Whether to insert spaces around brackets in object literals. + Defaults to true. --jsx-quote-style= The type of quotes used in JSX. Defaults to double. --quote-properties= When properties in objects are quoted. Defaults to asNeeded. --trailing-comma= Print trailing commas wherever possible in multi-line comma-separated @@ -43,8 +45,6 @@ The configuration that is contained inside the file `biome.json` only in for statements where it is necessary because of ASI. --arrow-parentheses= Whether to add non-necessary parentheses to arrow functions. Defaults to "always". - --bracket-spacing= Whether to insert spaces around brackets in object literals. - Defaults to true. --bracket-same-line= Whether to hug the closing bracket of multiline HTML/JSX tags to the end of the last line, rather than being alone on the following line. Defaults to false. diff --git a/crates/biome_cli/tests/snapshots/main_commands_format/applies_custom_bracket_spacing_graphql.snap b/crates/biome_cli/tests/snapshots/main_commands_format/applies_custom_bracket_spacing_graphql.snap new file mode 100644 index 000000000000..fe17d3a0ddbe --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_commands_format/applies_custom_bracket_spacing_graphql.snap @@ -0,0 +1,18 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: content +--- +## `file.graphql` + +```graphql +{ + field_value(object_value: {key: "value"}) +} + +``` + +# Emitted Messages + +```block +Formatted 1 file in