Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reduce accepted values for options #4271

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/reduced_accepted_values.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions .changeset/reduced_accepted_values_for_js_options.md
Original file line number Diff line number Diff line change
@@ -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"`.
9 changes: 9 additions & 0 deletions .changeset/reduced_accepted_values_of_options.md
Original file line number Diff line number Diff line change
@@ -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"`.
8 changes: 4 additions & 4 deletions crates/biome_formatter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ impl FromStr for QuoteStyle {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"double" | "Double" => Ok(Self::Double),
"single" | "Single" => Ok(Self::Single),
"double" => Ok(Self::Double),
"single" => Ok(Self::Single),
// TODO: replace this error with a diagnostic
_ => Err("Value not supported for QuoteStyle"),
}
Expand Down Expand Up @@ -626,8 +626,8 @@ impl FromStr for AttributePosition {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"multiline" | "Multiline" => Ok(Self::Multiline),
"auto" | "Auto" => Ok(Self::Auto),
"multiline" => Ok(Self::Multiline),
"auto" => Ok(Self::Auto),
_ => Err("Value not supported for attribute_position. Supported values are 'auto' and 'multiline'."),
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/biome_js_formatter/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ impl FromStr for QuoteProperties {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"as-needed" | "AsNeeded" => Ok(Self::AsNeeded),
"preserve" | "Preserve" => Ok(Self::Preserve),
"as-needed" => Ok(Self::AsNeeded),
"preserve" => Ok(Self::Preserve),
// TODO: replace this error with a diagnostic
_ => Err("Value not supported for QuoteProperties"),
}
Expand Down Expand Up @@ -464,8 +464,8 @@ impl FromStr for Semicolons {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"as-needed" | "AsNeeded" => Ok(Self::AsNeeded),
"always" | "Always" => Ok(Self::Always),
"as-needed" => Ok(Self::AsNeeded),
"always" => Ok(Self::Always),
_ => Err("Value not supported for Semicolons. Supported values are 'as-needed' and 'always'."),
}
}
Expand Down Expand Up @@ -508,8 +508,8 @@ impl FromStr for ArrowParentheses {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"as-needed" | "AsNeeded" => Ok(Self::AsNeeded),
"always" | "Always" => Ok(Self::Always),
"as-needed" => Ok(Self::AsNeeded),
"always" => Ok(Self::Always),
_ => Err("Value not supported for Arrow parentheses. Supported values are 'as-needed' and 'always'."),
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_js_formatter/src/context/trailing_commas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ impl FromStr for TrailingCommas {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"es5" | "ES5" => Ok(Self::Es5),
"all" | "All" => Ok(Self::All),
"none" | "None" => Ok(Self::None),
"es5" => Ok(Self::Es5),
"all" => Ok(Self::All),
"none" => Ok(Self::None),
// TODO: replace this error with a diagnostic
_ => Err("Value not supported for TrailingCommas"),
}
Expand Down