Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
fix: codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Apr 22, 2023
1 parent 55e58af commit e4013b5
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 18 deletions.
3 changes: 2 additions & 1 deletion crates/rome_formatter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ impl std::fmt::Display for IndentStyle {
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema),
serde(rename_all = "camelCase")
)]
pub struct LineWidth(u16);

Expand Down
9 changes: 6 additions & 3 deletions crates/rome_js_formatter/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ impl fmt::Display for JsFormatOptions {
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema),
serde(rename_all = "camelCase")
)]
#[derive(Default)]
pub enum QuoteStyle {
Expand Down Expand Up @@ -361,7 +362,8 @@ impl VisitNode<JsonLanguage> for QuoteStyle {
#[derive(Debug, Eq, PartialEq, Clone, Copy, Default)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema),
serde(rename_all = "camelCase")
)]
pub enum QuoteProperties {
#[default]
Expand Down Expand Up @@ -414,7 +416,8 @@ impl VisitNode<JsonLanguage> for QuoteProperties {
#[derive(Debug, Eq, PartialEq, Clone, Copy, Default)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema),
serde(rename_all = "camelCase")
)]
pub enum Semicolons {
#[default]
Expand Down
15 changes: 8 additions & 7 deletions crates/rome_js_formatter/src/context/trailing_comma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::str::FromStr;
pub(crate) enum FormatTrailingComma {
/// Print trailing comma if the option is [TrailingComma::All].
All,
/// Print trailing comma if the option is [TrailingComma::All] or [TrailingComma::ES5].
/// Print trailing comma if the option is [TrailingComma::All] or [TrailingComma::Es5].
ES5,
}

Expand Down Expand Up @@ -58,14 +58,15 @@ impl Format<JsFormatContext> for FormatTrailingComma {
#[derive(Default, Debug, Eq, PartialEq, Clone, Copy)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema),
serde(rename_all = "camelCase")
)]
pub enum TrailingComma {
/// Trailing commas wherever possible (including function parameters and calls).
#[default]
All,
/// Trailing commas where valid in ES5 (objects, arrays, etc.). No trailing commas in type parameters in TypeScript.
ES5,
Es5,
/// No trailing commas.
None,
}
Expand All @@ -74,7 +75,7 @@ impl TrailingComma {
pub(crate) const KNOWN_VALUES: &'static [&'static str] = &["all", "es5", "none"];

pub const fn is_es5(&self) -> bool {
matches!(self, TrailingComma::ES5)
matches!(self, TrailingComma::Es5)
}
pub const fn is_all(&self) -> bool {
matches!(self, TrailingComma::All)
Expand All @@ -89,7 +90,7 @@ impl FromStr for TrailingComma {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"es5" | "ES5" => Ok(Self::ES5),
"es5" | "ES5" => Ok(Self::Es5),
"all" | "All" => Ok(Self::All),
"none" | "None" => Ok(Self::None),
// TODO: replace this error with a diagnostic
Expand All @@ -101,7 +102,7 @@ impl FromStr for TrailingComma {
impl fmt::Display for TrailingComma {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TrailingComma::ES5 => std::write!(f, "ES5"),
TrailingComma::Es5 => std::write!(f, "ES5"),
TrailingComma::All => std::write!(f, "All"),
TrailingComma::None => std::write!(f, "None"),
}
Expand All @@ -120,7 +121,7 @@ impl VisitNode<JsonLanguage> for TrailingComma {
*self = TrailingComma::All;
}
"es5" => {
*self = TrailingComma::ES5;
*self = TrailingComma::Es5;
}
"none" => {
*self = TrailingComma::None;
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_formatter/tests/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl From<JsSerializableTrailingComma> for TrailingComma {
fn from(test: JsSerializableTrailingComma) -> Self {
match test {
JsSerializableTrailingComma::All => TrailingComma::All,
JsSerializableTrailingComma::ES5 => TrailingComma::ES5,
JsSerializableTrailingComma::ES5 => TrailingComma::Es5,
JsSerializableTrailingComma::None => TrailingComma::None,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ impl VisitNode<JsonLanguage> for JavascriptFormatter {
"quoteStyle" => {
let mut quote_style = QuoteStyle::default();
self.map_to_known_string(&value, name_text, &mut quote_style, diagnostics)?;
self.quote_style = quote_style.into();
self.quote_style = quote_style;
}
"trailingComma" => {
let mut trailing_comma = TrailingComma::default();
self.map_to_known_string(&value, name_text, &mut trailing_comma, diagnostics)?;
self.trailing_comma = trailing_comma.into();
self.trailing_comma = trailing_comma;
}
"quoteProperties" => {
let mut quote_properties = QuoteProperties::default();
self.map_to_known_string(&value, name_text, &mut quote_properties, diagnostics)?;
self.quote_properties = quote_properties.into();
self.quote_properties = quote_properties;
}
"semicolons" => {
let mut semicolons = Semicolons::default();
self.map_to_known_string(&value, name_text, &mut semicolons, diagnostics)?;
self.semicolons = semicolons.into();
self.semicolons = semicolons;
}
_ => {}
}
Expand Down
21 changes: 20 additions & 1 deletion editors/vscode/configuration_schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions npm/backend-jsonrpc/src/workspace.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion npm/rome/configuration_schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4013b5

Please sign in to comment.